-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (168 loc) · 7.13 KB
/
release.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
name: Create Release
on:
push:
branches:
- main
- '[0-9]+.*'
jobs:
createReleaseVersion:
name: Create Release Version
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
releaseVersion: ${{ steps.release.outputs.releaseVersion }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: |
npm ci
- name: Lint
run: |
npm run lint -- -- --no-fix --max-warnings 0
- name: Test
run: |
npm run test:ci
- name: App type check
working-directory: ./packages/app
run: |
npm run typecheck
- name: Create Release Version
id: release
env:
GITHUB_TOKEN: ${{ github.token }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
VITE_APP_ENVIRONMENT=production \
npx semantic-release
deployBackendToStaging:
name: Deploy Block Explorer backend to staging
runs-on: [matterlabs-ci-runner]
permissions:
contents: read
needs: createReleaseVersion
if: ${{ github.ref == 'refs/heads/main' && needs.createReleaseVersion.outputs.releaseVersion != '' }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate build ID for Flux Image Automation
id: setVersionForFlux
run: |
sha=$(git rev-parse --short HEAD)
ts=$(date +%s%N | cut -b1-13)
echo "::set-output name=imageTag::${sha}-${ts}"
- name: Auth to google artifact registry
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Build and push Docker image for API
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-api:latest"
"matterlabs/block-explorer-api:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-api:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-api:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/api/Dockerfile
no-cache: true
- name: Build and push Docker image for Worker
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-worker:latest"
"matterlabs/block-explorer-worker:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-worker:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-worker:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/worker/Dockerfile
no-cache: true
- name: Build and push Docker image for Data Fetcher
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-data-fetcher:latest"
"matterlabs/block-explorer-data-fetcher:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-data-fetcher:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-data-fetcher:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/data-fetcher/Dockerfile
no-cache: true
- name: Build and push Docker image for App
uses: docker/build-push-action@v4
with:
push: true
tags: |
"matterlabs/block-explorer-app:latest"
"matterlabs/block-explorer-app:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"matterlabs/block-explorer-app:${{ steps.setVersionForFlux.outputs.imageTag }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:latest"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
"us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/block-explorer-app:${{ steps.setVersionForFlux.outputs.imageTag }}"
file: packages/app/Dockerfile
no-cache: true
deployFrontendToStaging:
name: Deploy Block Explorer frontend to staging
runs-on: matterlabs-firebase-deployer
permissions:
contents: read
needs: createReleaseVersion
if: ${{ github.ref == 'refs/heads/main' && needs.createReleaseVersion.outputs.releaseVersion != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Firebase CLI and auth
run: |
npm install -g firebase-tools
- name: Download Dist package
uses: dsaltares/fetch-gh-release-asset@master
with:
version: "tags/v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
file: "dist.zip"
target: "dist.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Unzip Dist package
run: |
unzip dist.zip -d packages/app
- name: Update config
run: |
echo "window[\"##runtimeConfig\"] = { appEnvironment: \"staging\", sentryDSN: \"${{ vars.SENTRY_DSN }}\" };" > packages/app/dist/config.js
- name: Download Storybook package
uses: dsaltares/fetch-gh-release-asset@master
with:
version: "tags/v${{ needs.createReleaseVersion.outputs.releaseVersion }}"
file: "storybook-static.zip"
target: "storybook-static.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Unzip Storybook package
run: |
unzip storybook-static.zip -d packages/app
- name: Deploy
working-directory: ./packages/app
run: |
firebase --project staging-scan-v2 deploy