[Buildkite] Perform PR commentary in pipeline and remove github action (#614)

* [Buildkite] Perform PR commentary in pipeline and remove github action

* [Buildkite] Optimise deployment post-command hook
pull/611/head^2
Amir Zarrinkafsh 2020-02-03 20:07:01 +11:00 committed by GitHub
parent 9f904eb27e
commit 9c9d8518eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 51 deletions

View File

@ -14,8 +14,18 @@ if [[ $BUILDKITE_LABEL =~ ":docker: Deploy" ]]; then
docker logout docker logout
fi fi
if [[ $BUILDKITE_BRANCH == "master" ]] || [[ $BUILDKITE_BRANCH =~ ^v.* ]] && [[ $BUILDKITE_PULL_REQUEST == "false" ]]; then if [[ $BUILDKITE_LABEL == ":docker: Deploy Manifests" ]] && [[ $BUILDKITE_PULL_REQUEST != "false" ]]; then
if [[ $BUILDKITE_LABEL == ":docker: Deploy Manifests" ]]; then if [[ ! $(curl -fs --retry 3 "https://api.github.com/repos/authelia/authelia/issues/${BUILDKITE_PULL_REQUEST}/comments" | jq '.[].user.login') =~ autheliabot ]]; then
echo "--- :github: Add deployment commentary"
if [[ $BUILDKITE_PULL_REQUEST_REPO == "git://github.com/authelia/authelia.git" ]]; then
curl -fs --retry 3 -H "Authorization: token ${GITHUB_COMMENT_TOKEN}" -X "POST" -d "{\"body\": \"# Docker Container\nThese changes are published for testing at the following location:\n* \`docker pull authelia/authelia:${BUILDKITE_BRANCH}\`\"}" "https://api.github.com/repos/authelia/authelia/issues/${BUILDKITE_PULL_REQUEST}/comments"
else
curl -fs --retry 3 -H "Authorization: token ${GITHUB_COMMENT_TOKEN}" -X "POST" -d "{\"body\": \"# Docker Container\nThese changes are published for testing at the following location:\n* \`docker pull authelia/authelia:PR${BUILDKITE_PULL_REQUEST}\`\"}" "https://api.github.com/repos/authelia/authelia/issues/${BUILDKITE_PULL_REQUEST}/comments"
fi
fi
fi
if [[ $BUILDKITE_LABEL == ":docker: Deploy Manifests" ]] && [[ $BUILDKITE_BRANCH == "master" ]] || [[ $BUILDKITE_BRANCH =~ ^v.* ]] && [[ $BUILDKITE_PULL_REQUEST == "false" ]]; then
echo "--- :docker: Removing tags for deleted branches" echo "--- :docker: Removing tags for deleted branches"
for BRANCH_TAG in $(dockerbranchtags=$(anontoken=$(curl -fsL --retry 3 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:authelia/authelia:pull' | jq -r .token) && \ for BRANCH_TAG in $(dockerbranchtags=$(anontoken=$(curl -fsL --retry 3 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:authelia/authelia:pull' | jq -r .token) && \
curl -fsL --retry 3 -H "Authorization: Bearer ${anontoken}" https://registry-1.docker.io/v2/authelia/authelia/tags/list | jq -r '.tags[] | select(startswith("PR") | not)' | \ curl -fsL --retry 3 -H "Authorization: Bearer ${anontoken}" https://registry-1.docker.io/v2/authelia/authelia/tags/list | jq -r '.tags[] | select(startswith("PR") | not)' | \
@ -33,5 +43,4 @@ if [[ $BUILDKITE_BRANCH == "master" ]] || [[ $BUILDKITE_BRANCH =~ ^v.* ]] && [[
echo "Removing tag ${PR_TAG}" echo "Removing tag ${PR_TAG}"
curl -fsL --retry 3 -o /dev/null -X "DELETE" -H "Authorization: JWT ${authtoken}" https://hub.docker.com/v2/repositories/authelia/authelia/tags/${PR_TAG}/ curl -fsL --retry 3 -o /dev/null -X "DELETE" -H "Authorization: JWT ${authtoken}" https://hub.docker.com/v2/repositories/authelia/authelia/tags/${PR_TAG}/
done done
fi
fi fi

View File

@ -1,31 +0,0 @@
name: Docker Image CD
on:
pull_request:
types: [opened]
jobs:
example_comment_pr:
runs-on: ubuntu-latest
name: Commentary
steps:
- name: Checkout
uses: authelia/checkout@v1
- name: Comment PR
uses: authelia/actions-comment-pull-request@master
with:
message: '# Containers
These changes are published as containers for testing at one of the following locations:
#### Local Branch
* `docker pull authelia/authelia:${{ github.head_ref }}`
#### Pull Request
* `docker pull authelia/authelia:PR${{ github.event.pull_request.number }}`
Pull Requests require approval from an Authelia team member to deploy.'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}