Skip to content

Commit 901d065

Browse files
committed
Add GitHub Actions workflow for deploying downstream clusters
1 parent 25866f8 commit 901d065

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Deploy: Downstream Clusters"
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Image tag to deploy (e.g. 1.1.0)'
10+
required: true
11+
default: 'latest'
12+
13+
jobs:
14+
update-sandbox:
15+
name: Update Sandbox Cluster
16+
runs-on: ubuntu-latest
17+
outputs:
18+
tag: ${{ steps.get_tag.outputs.TAG }}
19+
steps:
20+
- name: Checkout App
21+
uses: actions/checkout@v4
22+
23+
- name: Get Release Tag
24+
id: get_tag
25+
run: |
26+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
27+
echo "TAG=${{ inputs.tag }}" >> $GITHUB_OUTPUT
28+
else
29+
echo "TAG=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
30+
fi
31+
32+
- name: Checkout Sandbox Cluster
33+
uses: actions/checkout@v4
34+
with:
35+
repository: CodeForPhilly/cfp-sandbox-cluster
36+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
37+
path: sandbox
38+
39+
- name: Update Sandbox Image Tag
40+
working-directory: sandbox/balancer
41+
run: |
42+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
43+
./kustomize edit set image ghcr.io/codeforphilly/balancer-main/app:${{ steps.get_tag.outputs.TAG }}
44+
rm kustomize
45+
46+
- name: Create Sandbox PR
47+
uses: peter-evans/create-pull-request@v6
48+
with:
49+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
50+
path: sandbox
51+
commit-message: "Deploy balancer ${{ steps.get_tag.outputs.TAG }} to sandbox"
52+
title: "Deploy balancer ${{ steps.get_tag.outputs.TAG }}"
53+
body: "Updates balancer image tag to ${{ steps.get_tag.outputs.TAG }}"
54+
branch: "deploy/balancer-${{ steps.get_tag.outputs.TAG }}"
55+
base: main
56+
delete-branch: true
57+
58+
update-live:
59+
name: Update Live Cluster
60+
needs: update-sandbox
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout Live Cluster
64+
uses: actions/checkout@v4
65+
with:
66+
repository: CodeForPhilly/cfp-live-cluster
67+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
68+
path: live
69+
70+
- name: Update Live Image Tag
71+
working-directory: live/balancer
72+
run: |
73+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
74+
./kustomize edit set image ghcr.io/codeforphilly/balancer-main/app:${{ needs.update-sandbox.outputs.tag }}
75+
rm kustomize
76+
77+
- name: Create Live PR
78+
uses: peter-evans/create-pull-request@v6
79+
with:
80+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
81+
path: live
82+
commit-message: "Deploy balancer ${{ needs.update-sandbox.outputs.tag }} to live"
83+
title: "Deploy balancer ${{ needs.update-sandbox.outputs.tag }}"
84+
body: "Updates balancer image tag to ${{ needs.update-sandbox.outputs.tag }}"
85+
branch: "deploy/balancer-${{ needs.update-sandbox.outputs.tag }}"
86+
base: main
87+
delete-branch: true

0 commit comments

Comments
 (0)