-
Notifications
You must be signed in to change notification settings - Fork 12
243 lines (234 loc) · 10.4 KB
/
connect-button-ci.yml
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: 'Connect button CI/CD'
on:
pull_request:
# branches:
# - develop
push:
branches:
- develop
- main
env:
jenkins_job_name: 'kubernetes-deployments/job/connect-button'
helm_dir: 'deploy/helm/connect-button'
dev_eks_cluster: 'rdx-works-main-dev'
prod_eks_cluster: 'rdx-works-main-dev'
jobs:
build_push_container:
permissions:
packages: write
id-token: write
pull-requests: write
contents: read
name: Build and push docker image
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: ubuntu-latest
image_registry: 'docker.io'
image_organization: 'radixdlt'
image_name: 'connect-button-storybook'
tag: ${{ needs.build.outputs.tag }}
tags: |
type=sha,priority=601
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
context: './'
dockerfile: './packages/connect-button/Dockerfile'
platforms: 'linux/amd64'
provenance: 'false'
enable_gcr: 'false'
scan_image: true
snyk_target_ref: ${{ github.ref_name }}
secrets:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDP }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
deploy_pull_request:
if: ${{ github.event.pull_request }}
name: Deploy PR
runs-on: ubuntu-latest
needs:
- build_push_container
permissions:
id-token: write
contents: read
pull-requests: read
steps:
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'connect-button'
step_name: 'deploy-pr'
secret_prefix: 'GH'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/jenkins-credentials-RTHKoO'
parse_json: true
- name: Connect to tailnet
uses: radixdlt/public-iac-resuable-artifacts/tailnet@main
with:
role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access"
region: "eu-west-2"
secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80"
- name: Trigger jenkins job to deploy PR
uses: RDXWorks-actions/jenkins-job-trigger-action@master
with:
jenkins_url: ${{ env.GH_JENKINS_URL }}
jenkins_user: ${{ env.GH_JENKINS_USER }}
jenkins_token: ${{ env.GH_JENKINS_API_TOKEN }}
job_name: ${{ env.jenkins_job_name }}
job_params: |
{
"git_repo" : "${{ github.repository }}",
"git_branch" : "${{ github.head_ref }}",
"helmfile_environment": "pr",
"hierarchical_namespace": "connect-button-ci-pr",
"namespace" : "connect-button-pr-${{ github.event.number }}",
"create_subnamespace" : "true",
"aws_region" : "eu-west-2",
"aws_iam_role": "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/jenkins-connect-button-pr-deployer",
"aws_eks_cluster" : "${{ env.dev_eks_cluster }}",
"helm_folder" : "${{ env.helm_dir }}",
"helmfile_extra_vars" : "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }},ci.prNumber=${{ github.event.number }}"
}
job_timeout: "3600"
fetch_logs: "false"
- name: Write URL to GH summary
run: |
echo "PR URL is: https://connect-button-storybook-pr-${{ github.event.number }}.rdx-works-main.extratools.works" >> $GITHUB_STEP_SUMMARY
deploy_dev:
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
name: Deploy DEV
runs-on: ubuntu-latest
needs:
- build_push_container
permissions:
id-token: write
contents: read
pull-requests: read
steps:
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'connect-button'
step_name: 'deploy-dev'
secret_prefix: 'GH'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/jenkins-credentials-RTHKoO'
parse_json: true
- name: Connect to tailnet
uses: radixdlt/public-iac-resuable-artifacts/tailnet@main
with:
role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access"
region: "eu-west-2"
secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80"
- name: Trigger jenkins job to deploy DEV
uses: RDXWorks-actions/jenkins-job-trigger-action@master
with:
jenkins_url: ${{ env.GH_JENKINS_URL }}
jenkins_user: ${{ env.GH_JENKINS_USER }}
jenkins_token: ${{ env.GH_JENKINS_API_TOKEN }}
job_name: ${{ env.jenkins_job_name }}
job_params: |
{
"git_repo" : "${{ github.repository }}",
"git_branch" : "${{ github.head_ref }}",
"helmfile_environment": "dev",
"namespace" : "connect-button-dev",
"aws_region" : "eu-west-2",
"aws_iam_role": "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/jenkins-connect-button-dev-deployer",
"aws_eks_cluster" : "${{ env.dev_eks_cluster }}",
"helm_folder" : "${{ env.helm_dir }}",
"helmfile_extra_vars" : "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }}"
}
job_timeout: "3600"
fetch_logs: "false"
deploy_prod:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Deploy PROD
runs-on: ubuntu-latest
needs:
- build_push_container
permissions:
id-token: write
contents: read
pull-requests: read
steps:
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'connect-button'
step_name: 'deploy-prod'
secret_prefix: 'GH'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/jenkins-credentials-RTHKoO'
parse_json: true
- name: Connect to tailnet
uses: radixdlt/public-iac-resuable-artifacts/tailnet@main
with:
role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access"
region: "eu-west-2"
secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80"
- name: Trigger jenkins job to deploy DEV
uses: RDXWorks-actions/jenkins-job-trigger-action@master
with:
jenkins_url: ${{ env.GH_JENKINS_URL }}
jenkins_user: ${{ env.GH_JENKINS_USER }}
jenkins_token: ${{ env.GH_JENKINS_API_TOKEN }}
job_name: ${{ env.jenkins_job_name }}
job_params: |
{
"git_repo" : "${{ github.repository }}",
"git_branch" : "${{ github.head_ref }}",
"helmfile_environment": "prod",
"namespace" : "connect-button-prod",
"aws_region" : "eu-west-2",
"aws_iam_role": "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/jenkins-connect-button-prod-deployer",
"aws_eks_cluster" : "${{ env.dev_eks_cluster }}",
"helm_folder" : "${{ env.helm_dir }}",
"helmfile_extra_vars" : "ci.tag=${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }}"
}
job_timeout: "3600"
fetch_logs: "false"
snyk_container_monitor:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
needs:
- build_push_container
permissions:
id-token: write
pull-requests: read
contents: read
deployments: write
steps:
- uses: radixdlt/public-iac-resuable-artifacts/snyk-container-monitor@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'cnct-button'
dockerhub_secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/dockerhub-credentials'
snyk_secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
snyk_org_id: ${{ secrets.SNYK_ORG_ID }}
image: docker.io/radixdlt/connect-button-storybook:${{ fromJSON(needs.build_push_container.outputs.json).labels['org.opencontainers.image.version'] }}
target_ref: ${{ github.ref_name }}
snyk_monitor:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
needs:
- build_push_container
permissions:
id-token: write
pull-requests: read
contents: read
deployments: write
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'connect-button'
step_name: 'snyk-monitor'
secret_prefix: 'SNYK'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
parse_json: true
- name: Enable Snyk online monitoring to check for vulnerabilities
uses: RDXWorks-actions/snyk-actions/node@master
with:
args: --all-projects --org=${{ env.SNYK_PROJECTS_ORG_ID }} --target-reference=${{ github.ref_name }}
command: monitor