Skip to content

Commit d187f3b

Browse files
committed
Refactor deployment workflows based on GitHub Releases
1 parent 46a532f commit d187f3b

File tree

9 files changed

+354
-294
lines changed

9 files changed

+354
-294
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 107 deletions
This file was deleted.

.github/workflows/dockerpublish.yml

Lines changed: 0 additions & 128 deletions
This file was deleted.

.github/workflows/heroku.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy working development app to Heroku staging project
1+
name: Deploy develop to Heroku
22

33
on:
44
push:

.github/workflows/infra-deploy.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy to production
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- releases/v1
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
- closed
12+
13+
env:
14+
KUBE_CONFIG_DATA: ${{ secrets.kubeconfig_data_prod }}
15+
16+
jobs:
17+
deploy-prod:
18+
if: github.event.pull_request.merged
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0 # Get full history for tag lookup
25+
- uses: azure/setup-kubectl@v1
26+
with:
27+
version: v1.18.0
28+
29+
- name: Add kubeconfig to environment
30+
run: |
31+
set -e
32+
test -e ~/.kube || mkdir ~/.kube
33+
cat <<EOF > ~/.kube/config
34+
$(printf '%s' "$KUBE_CONFIG_DATA" | base64 -d)
35+
EOF
36+
37+
- name: Get release version
38+
run: |
39+
# Find tag ref
40+
git fetch --tags
41+
ref=$(git describe --abbrev=0 --match 'v*' --exclude 'v*-rc.*' --tags ${{ github.sha }})
42+
echo "::set-env name=DEPLOY_REF::$ref"
43+
44+
if [ -z "$ref" ]; then
45+
echo error: could not find release tag for commit $head_sha
46+
exit 1
47+
fi
48+
49+
- name: Get manifest archive
50+
run: |
51+
set -e
52+
tagname=${{ env.DEPLOY_REF }}
53+
arc_fname=deploy-$tagname.zip
54+
arc_url=https://github.com/${{ github.repository }}/releases/download/$tagname/$arc_fname
55+
curl -fLO "$arc_url"
56+
unzip $arc_fname
57+
58+
- name: Deploy to prod
59+
run: |
60+
set -e
61+
echo deploying CHIME release ${{ env.DEPLOY_REF }}
62+
find deploy-${{ env.DEPLOY_REF }}/ -type f -print0 | xargs -0 cat | kubectl diff -f - || true
63+
kubectl apply -Rf deploy-${{ env.DEPLOY_REF }}
64+
65+
- name: Wait for deployment to complete
66+
run: |
67+
kubectl -n chime rollout status deployment.v1.apps/chime
68+
kubectl -n chime get deployment chime -o yaml

0 commit comments

Comments
 (0)