-
-
Notifications
You must be signed in to change notification settings - Fork 17
110 lines (99 loc) · 3.94 KB
/
deploy-downstream.yml
File metadata and controls
110 lines (99 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: "Deploy: Downstream Clusters"
on:
workflow_run:
workflows: ["Containers: Publish"]
types:
- completed
workflow_dispatch:
inputs:
tag:
description: 'Image tag to deploy (e.g. 1.1.0)'
required: true
default: 'latest'
jobs:
update-sandbox:
name: Update Sandbox Cluster
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'develop') }}
outputs:
tag: ${{ steps.get_tag.outputs.TAG }}
steps:
- name: Checkout App
uses: actions/checkout@v4
- name: Get Release Tag
id: get_tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "TAG=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
gh run download ${{ github.event.workflow_run.id }} -n docker-tag
TAG=$(cat docker_tag.txt)
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Sandbox Cluster
uses: actions/checkout@v4
with:
repository: CodeForPhilly/cfp-sandbox-cluster
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: sandbox
- name: Update Sandbox Image Tag
working-directory: sandbox/balancer
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
./kustomize edit set image ghcr.io/codeforphilly/balancer-main/app:${{ steps.get_tag.outputs.TAG }}
rm kustomize
- name: Create Sandbox PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: sandbox
commit-message: "Deploy balancer ${{ steps.get_tag.outputs.TAG }} to sandbox"
title: "Deploy balancer ${{ steps.get_tag.outputs.TAG }}"
body: "Updates balancer image tag to ${{ steps.get_tag.outputs.TAG }}"
branch: "deploy/balancer-${{ steps.get_tag.outputs.TAG }}"
base: main
delete-branch: true
update-live:
name: Update Live Cluster
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'release') }}
steps:
- name: Checkout App
uses: actions/checkout@v4
- name: Get Release Tag
id: get_tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "TAG=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
gh run download ${{ github.event.workflow_run.id }} -n docker-tag
TAG=$(cat docker_tag.txt)
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Live Cluster
uses: actions/checkout@v4
with:
repository: CodeForPhilly/cfp-live-cluster
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: live
- name: Update Live Image Tag
working-directory: live/balancer
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
./kustomize edit set image ghcr.io/codeforphilly/balancer-main/app:${{ steps.get_tag.outputs.TAG }}
rm kustomize
- name: Create Live PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: live
commit-message: "Deploy balancer ${{ steps.get_tag.outputs.TAG }} to live"
title: "Deploy balancer ${{ steps.get_tag.outputs.TAG }}"
body: "Updates balancer image tag to ${{ steps.get_tag.outputs.TAG }}"
branch: "deploy/balancer-${{ steps.get_tag.outputs.TAG }}"
base: main
delete-branch: true