-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (186 loc) · 6.57 KB
/
stg-deploy.yaml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Staging Deploy
on:
pull_request:
push:
branches:
- main
permissions:
id-token: write
contents: read
pull-requests: read
packages: write
jobs:
filter:
runs-on: ubuntu-latest
outputs:
kube: ${{ steps.path-filter.outputs.kube }}
svcmtr: ${{ steps.path-filter.outputs.svcmtr }}
gcp: ${{ steps.path-filter.outputs.gcp }}
aws: ${{ steps.path-filter.outputs.aws }}
fluxupd: ${{ steps.path-filter.outputs.fluxupd }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: path-filter
with:
filters: |
kube:
- "kubernetes/**"
- ".github/workflows/stg-deploy.yaml"
svcmtr:
- "service-monitor/**"
- ".github/workflows/stg-deploy.yaml"
gcp:
- "gcp/**"
- ".github/workflows/stg-deploy.yaml"
aws:
- "aws/**"
- ".github/workflows/stg-deploy.yaml"
fluxupd:
- "flux-target-updater/**"
- ".github/workflows/stg-deploy.yaml"
kube:
runs-on: ubuntu-latest
needs: filter
environment: staging # 管理者の承認を必要とする
if: needs.filter.outputs.kube == 'true' && github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/kube-deploy-stg
with:
slack-bot-token: ${{ secrets.SLACK_NOTIFIER_TOKEN }}
slack-channel-id: ${{ vars.STG_SLACK_CHANNEL_ID }}
target-branch: ${{ github.head_ref }}
flux-target-updater-token: ${{ secrets.FLUX_TARGET_UPDATER_TOKEN }}
action-link: ${{ github.event.pull_request.html_url }}
kube-main:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.kube == 'true' && github.event_name == 'push' && github.ref_name == 'main'
steps:
- uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/kube-deploy-stg
with:
slack-bot-token: ${{ secrets.SLACK_NOTIFIER_TOKEN }}
slack-channel-id: ${{ vars.STG_SLACK_CHANNEL_ID }}
target-branch: main
flux-target-updater-token: ${{ secrets.FLUX_TARGET_UPDATER_TOKEN }}
action-link: ${{ github.event.repository.html_url }}/commit/${{ github.sha }}
service-monitor:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.svcmtr == 'true' && github.event_name == 'pull_request'
environment: staging # 管理者の承認を必要とする
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/service-monitor-deploy
with:
func-name: stg-service-monitor
aws-region: ${{ secrets.AWS_REGION }}
aws-update-health-check-arn: ${{ vars.AWS_GITHUB_ACTIONS_ROLE_ARN }}
service-monitor-main:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.svcmtr == 'true' && github.event_name == 'push' && github.ref_name == 'main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/service-monitor-deploy
with:
func-name: stg-service-monitor
aws-region: ${{ secrets.AWS_REGION }}
aws-update-health-check-arn: ${{ vars.AWS_GITHUB_ACTIONS_ROLE_ARN }}
fluxupd:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.fluxupd == 'true' && github.event_name == 'pull_request'
environment: staging # 管理者の承認を必要とする
steps:
- name: Get current datetime
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Check out
uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/fluxupd-deploy
with:
github-actor: ${{ github.actor }}
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/piny940/flux-target-updater:main-${{ github.sha }}-${{ env.TIMESTAMP }}
fluxupd-main:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.fluxupd == 'true' && github.event_name == 'push' && github.ref_name == 'main'
steps:
- name: Get current datetime
run: echo "TIMESTAMP=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Check out
uses: actions/checkout@v4
- name: Deploy
uses: ./.github/actions/fluxupd-deploy
with:
github-actor: ${{ github.actor }}
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/piny940/flux-target-updater:main-${{ github.sha }}-${{ env.TIMESTAMP }}
gcp-apply:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.gcp == 'true' && github.event_name == 'pull_request'
environment: staging # 管理者の承認を必要とする
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Apply
uses: ./.github/actions/gcp-apply
with:
env: staging
gcp-project: ${{ vars.STG_GCP_PROJECT }}
gcp-project-number: ${{ vars.STG_GCP_PROJECT_NUMBER }}
gcp-apply-main:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.gcp == 'true' && github.event_name == 'push' && github.ref_name == 'main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Apply
uses: ./.github/actions/gcp-apply
with:
env: staging
gcp-project: ${{ vars.STG_GCP_PROJECT }}
gcp-project-number: ${{ vars.STG_GCP_PROJECT_NUMBER }}
aws-apply:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.aws == 'true' && github.event_name == 'pull_request'
environment: staging # 管理者の承認を必要とする
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Apply
uses: ./.github/actions/aws-apply
with:
env: "staging"
aws-region: ${{ vars.AWS_REGION }}
aws-role-arn: ${{ vars.AWS_GITHUB_ACTIONS_ROLE_ARN }}
gh-token: ${{ secrets.GITHUB_TOKEN }}
aws-apply-main:
runs-on: ubuntu-latest
needs: filter
if: needs.filter.outputs.aws == 'true' && github.event_name == 'push' && github.ref_name == 'main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Apply
uses: ./.github/actions/aws-apply
with:
env: "staging"
aws-region: ${{ vars.AWS_REGION }}
aws-role-arn: ${{ vars.AWS_GITHUB_ACTIONS_ROLE_ARN }}
gh-token: ${{ secrets.GITHUB_TOKEN }}