11name : " Deploy: Downstream Clusters"
22
33on :
4- release :
5- types : [published]
4+ workflow_run :
5+ workflows : ["Containers: Publish"]
6+ types :
7+ - completed
68 workflow_dispatch :
79 inputs :
810 tag :
1416 update-sandbox :
1517 name : Update Sandbox Cluster
1618 runs-on : ubuntu-latest
19+ if : ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop') }}
1720 outputs :
1821 tag : ${{ steps.get_tag.outputs.TAG }}
1922 steps :
2629 if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
2730 echo "TAG=${{ inputs.tag }}" >> $GITHUB_OUTPUT
2831 else
29- echo "TAG=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
32+ gh run download ${{ github.event.workflow_run.id }} -n docker-tag
33+ TAG=$(cat docker_tag.txt)
34+ echo "TAG=${TAG}" >> $GITHUB_OUTPUT
3035 fi
36+ env :
37+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3138
3239 - name : Checkout Sandbox Cluster
3340 uses : actions/checkout@v4
5764
5865 update-live :
5966 name : Update Live Cluster
60- needs : update-sandbox
6167 runs-on : ubuntu-latest
68+ if : ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'release') }}
6269 steps :
70+ - name : Checkout App
71+ uses : actions/checkout@v4
72+
73+ - name : Get Release Tag
74+ id : get_tag
75+ run : |
76+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
77+ echo "TAG=${{ inputs.tag }}" >> $GITHUB_OUTPUT
78+ else
79+ gh run download ${{ github.event.workflow_run.id }} -n docker-tag
80+ TAG=$(cat docker_tag.txt)
81+ echo "TAG=${TAG}" >> $GITHUB_OUTPUT
82+ fi
83+ env :
84+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85+
6386 - name : Checkout Live Cluster
6487 uses : actions/checkout@v4
6588 with :
@@ -71,17 +94,17 @@ jobs:
7194 working-directory : live/balancer
7295 run : |
7396 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 }}
97+ ./kustomize edit set image ghcr.io/codeforphilly/balancer-main/app:${{ steps.get_tag .outputs.TAG }}
7598 rm kustomize
7699
77100 - name : Create Live PR
78101 uses : peter-evans/create-pull-request@v6
79102 with :
80103 token : ${{ secrets.BOT_GITHUB_TOKEN }}
81104 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 }}"
105+ commit-message : " Deploy balancer ${{ steps.get_tag .outputs.TAG }} to live"
106+ title : " Deploy balancer ${{ steps.get_tag .outputs.TAG }}"
107+ body : " Updates balancer image tag to ${{ steps.get_tag .outputs.TAG }}"
108+ branch : " deploy/balancer-${{ steps.get_tag .outputs.TAG }}"
86109 base : main
87110 delete-branch : true
0 commit comments