Skip to content

Commit 8e716ea

Browse files
committed
Workflows to deploy tagged releases to preprod and prod
1 parent ed07e38 commit 8e716ea

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy to production
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- releases/v1
7+
types:
8+
- closed
9+
10+
env:
11+
# Required for action steebchen/kubectl
12+
KUBE_CONFIG_DATA: ${{ secrets.kubeconfig_data_prod }}
13+
14+
jobs:
15+
deploy-prod:
16+
if: github.event.pull_request.merged
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Deploy to prod
23+
uses: steebchen/[email protected]
24+
with:
25+
args: apply -f k8s/app.yaml
26+
27+
- name: Wait for deploy to complete
28+
uses: steebchen/[email protected]
29+
with:
30+
args: -n chime rollout status deployment.v1.apps/chime
31+
32+
- name: Show completed deployment
33+
uses: steebchen/[email protected]
34+
with:
35+
args: -n chime get deployment chime -o yaml

.github/workflows/dockerpublish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111

1212
env:
1313
IMAGE_NAME: penn-chime
14+
DEPLOY_PUSH_BRANCH: develop
15+
# Required for action steebchen/kubectl
16+
KUBE_CONFIG_DATA: ${{ secrets.kubeconfig_data_preprod }}
1417

1518
jobs:
1619
# Run tests.
@@ -66,3 +69,52 @@ jobs:
6669
6770
docker tag image $IMAGE_ID:$VERSION
6871
docker push $IMAGE_ID:$VERSION
72+
73+
deploy-preprod:
74+
75+
needs: push
76+
if: github.event_name == 'push'
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
with:
82+
fetch-depth: 0 # Needed for proper rebase
83+
- name: Update application manifest
84+
run: |
85+
# Strip git ref prefix from version
86+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
87+
88+
# Strip "v" prefix from tag name
89+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
90+
91+
# Update image version in application manifest
92+
sed -Ei "s,(- image: docker.pkg.github.com)(.*),\1/${{ github.repository }}/$IMAGE_NAME:$VERSION," k8s/app.yaml
93+
94+
# Show updated manifest file
95+
cat k8s/app.yaml
96+
97+
- name: Deploy to preprod
98+
uses: steebchen/[email protected]
99+
with:
100+
args: apply -f k8s/app.yaml
101+
102+
- name: Wait for deploy to complete
103+
uses: steebchen/[email protected]
104+
with:
105+
args: -n chime rollout status deployment.v1.apps/chime
106+
107+
- name: Show completed deployment
108+
uses: steebchen/[email protected]
109+
with:
110+
args: -n chime get deployment chime -o yaml
111+
112+
- name: Push manifest update
113+
uses: github-actions-x/[email protected]
114+
with:
115+
github-token: ${{ secrets.GITHUB_TOKEN }}
116+
push-branch: ${{ env.DEPLOY_PUSH_BRANCH }}
117+
commit-message: Deploy version ${VERSION} to preprod
118+
rebase: 'true'
119+
name: Chime CI
120+

0 commit comments

Comments
 (0)