-
Notifications
You must be signed in to change notification settings - Fork 38
219 lines (192 loc) · 7.13 KB
/
dispatch_release.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
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
name: "[Dispatch] Release"
on:
workflow_dispatch:
inputs:
version:
description: 'enter version(x.y.z)'
required: true
default: '2.0.0'
container_arch:
type: choice
description: 'choose container architecture'
default: linux/amd64
options:
- "linux/amd64"
- "linux/amd64,linux/arm64"
env:
ARCH: ${{ github.event.inputs.container_arch }}
VERSION: ${{ github.event.inputs.version }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
mirinae:
runs-on: ubuntu-latest
steps:
- name: Invoke mirinae release workflow
id: mirinae
uses: convictional/trigger-workflow-and-wait@v1.6.1
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
github_token: ${{ secrets.PAT_TOKEN }}
workflow_file_name: dispatch_mirinae_release.yaml
wait_workflow: true
propagate_failure: true
wait_interval: 5
ref: ${{ github.ref_name }}
storybook:
runs-on: ubuntu-latest
needs: mirinae
steps:
- name: Invoke storybook release workflow
uses: convictional/trigger-workflow-and-wait@v1.6.1
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
github_token: ${{ secrets.PAT_TOKEN }}
workflow_file_name: dispatch_storybook_release.yaml
wait_workflow: false
propagate_failure: false
ref: ${{ github.ref_name }}
versioning_and_docker:
runs-on: ubuntu-latest
needs: mirinae
outputs:
new_commit_sha: ${{ steps.get_sha.outputs.NEW_COMMIT_SHA }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Restore cached node_modules
id: restore-node-cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-modules-
- name: Install dependencies
if: steps.restore-node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Change version
run: |
converted_version=$(echo ${{ env.VERSION }} | sed -E 's/^([0-9]+\.[0-9]+)\.([a-zA-Z]+)/\1.0-\2/')
npm version $converted_version --no-git-tag-version --allow-same-version --no-commit-hooks --include-workspace-root -w=web
echo "converted_version=$converted_version" >> "$GITHUB_OUTPUT"
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6.2.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Configure git
run: |
git config --global user.signingkey "${{ secrets.CLOUDFORET_ADMIN_GPG_KEY_ID }}"
git config --global user.email "${{ vars.GIT_EMAIL }}"
git config --global user.name "${{ vars.GIT_USERNAME }}"
- name: Check if there are any changes
id: check_changes
run: |
git diff --exit-code --quiet || echo "::set-output name=changed::true"
continue-on-error: true
- name: Commit changes and Set current commit SHA to output
if: steps.check_changes.outputs.changed == 'true'
id: get_sha
run: |
git commit -s -am "chore: version ${{ env.VERSION }}"
echo "NEW_COMMIT_SHA=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
env:
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}
- name: Push changes
if: steps.check_changes.outputs.changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.CLOUDFORET_DEV_DOCKER_USERNAME }}
password: ${{ secrets.CLOUDFORET_DEV_DOCKER_PASSWORD }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REPO }}
- name: Build and push to dockerhub
uses: docker/build-push-action@v4
env:
BUILDKIT_COLORS: 1
with:
context: .
file: ./apps/web/Dockerfile
platforms: ${{ env.ARCH }}
push: true
cache-from: ${{ vars.DOCKER_REPO_OWNER }}/${{ github.event.repository.name }}:latest
cache-to: type=inline
tags: |
${{ vars.DOCKER_REPO_OWNER }}/${{ github.event.repository.name }}:latest
${{ vars.DOCKER_REPO_OWNER }}/${{ github.event.repository.name }}:${{ env.VERSION }}
${{ secrets.ECR_REPO }}/${{ github.event.repository.name }}:latest
${{ secrets.ECR_REPO }}/${{ github.event.repository.name }}:${{ env.VERSION }}
provenance: false
- name: Notice when job fails
if: failure()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack
tagging:
needs: versioning_and_docker
runs-on: ubuntu-latest
env:
NEW_COMMIT_SHA: ${{ needs.versioning_and_docker.outputs.new_commit_sha }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.NEW_COMMIT_SHA }}
- name: Configure git
run: |
git config --global user.email "${{ vars.GIT_EMAIL }}"
git config --global user.name "${{ vars.GIT_USERNAME }}"
- name: Git tagging
run: |
git tag ${{ env.VERSION }}
git push origin ${{ env.VERSION }}
- name: Notice when job fails
if: failure()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,workflow,job
author_name: Github Action Slack
notification:
needs: tagging
runs-on: ubuntu-latest
steps:
- name: Slack
if: always()
uses: 8398a7/action-slack@v3.15.0
with:
status: ${{job.status}}
fields: repo,message,commit,author,action,ref,workflow,job
author_name: Github Action Slack