Skip to content

Commit

Permalink
circleci: trigger pke image build after release
Browse files Browse the repository at this point in the history
  • Loading branch information
asdwsda committed Sep 18, 2019
1 parent 48b222a commit 30681cc
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
32 changes: 28 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,28 @@ jobs:
run:
name: Invalidate cloudfront edge cache
command: |
aws cloudfront create-invalidation \
--distribution-id ${CDN_DISTRIBUTION_ID} \
--paths "/downloads/pke/*"
aws cloudfront create-invalidation \
--distribution-id ${CDN_DISTRIBUTION_ID} \
--paths "/downloads/pke/*"
trigger-pke-image-build:
docker:
-
image: circleci/golang:1.12
resource_class: small
steps:
- checkout
-
run:
name: Create tag
command: |
scripts/create-git-tag.sh 'banzaicloud' 'pke-image' 'refs/heads/automated-build' "pke-${CIRCLE_TAG}"
workflows:
version: 2
build:
ci:
jobs:
-
build:
Expand All @@ -162,3 +177,12 @@ workflows:
only: /^v?\d+\.\d+\.\d+(-\S*)?$/
branches:
ignore: /.*/
-
trigger-pke-image-build:
requires:
- release
filters:
tags:
only: /^v?\d+\.\d+\.\d+(-\S*)?$/
branches:
ignore: /.*/
18 changes: 18 additions & 0 deletions create-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -euf

OWNER="$1"
REPO="$2"
REF="$3"
TAG="$4"

API_URL="https://api.github.com/repos/${OWNER}/${REPO}"

SHA=$(curl -sS -X GET -H "Authorization: token $GITHUB_TOKEN" "${API_URL}/git/${REF}" | jq -r '.object.sha')

curl \
-sS \
-X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sha": "'"${SHA}"'", "ref": "refs/tags/'"${TAG}"'"}' \
"${API_URL}/git/refs"
18 changes: 18 additions & 0 deletions scripts/create-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -euf

OWNER="$1"
REPO="$2"
REF="$3"
TAG="$4"

API_URL="https://api.github.com/repos/${OWNER}/${REPO}"

SHA=$(curl -sS -X GET -H "Authorization: token ${GITHUB_TOKEN}" "${API_URL}/git/${REF}" | jq -r '.object.sha')

curl \
-sS \
-X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"sha": "'"${SHA}"'", "ref": "refs/tags/'"${TAG}"'"}' \
"${API_URL}/git/refs"

0 comments on commit 30681cc

Please sign in to comment.