-
Notifications
You must be signed in to change notification settings - Fork 3
245 lines (208 loc) · 7.2 KB
/
ci.yml
File metadata and controls
245 lines (208 loc) · 7.2 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
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
244
245
name: CI
on:
push:
branches:
- main
- nic/env/fosdem-2023
pull_request:
env:
DOCKER_IMAGE: ghcr.io/nordeck/matrix-barcamp-widget
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
docker-tag: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
# required for changesets
fetch-depth: '0'
# don't persist the credentials so the changesets action doesn't use the
# github actions token but the git token provided via environment variable
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- name: yarn install
run: yarn install --frozen-lockfile
- name: prettier:check
run: yarn prettier:check
- name: depcheck
run: yarn depcheck
- name: lint
run: yarn lint
- name: type checking and declarations
run: yarn tsc
- name: check translations
run: yarn translate --fail-on-update
- name: test
run: yarn test:all
- name: build
run: yarn build
- name: generate disclaimer
run: yarn generate-disclaimer
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: true
with:
images: ${{ env.DOCKER_IMAGE }}
labels: |
org.opencontainers.image.title=Matrix BarCamp
org.opencontainers.image.description=A widget for organizing barcamps in matrix chat rooms
org.opencontainers.image.vendor=Nordeck IT + Consulting GmbH
tags: |
type=sha,prefix=
- name: Build and push
uses: docker/build-push-action@v3
id: dockerBuild
with:
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'pull_request' && secrets.GH_APP_OS_APP_ID != '' }}
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/s390x
- name: Generate GitHub token
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: generate_token
uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c # @v1.7.0
with:
app_id: ${{ secrets.GH_APP_OS_APP_ID }}
private_key: ${{ secrets.GH_APP_OS_PRIVATE_KEY }}
- name: Create Release Pull Request or Publish Packages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: changesets/action@e9cc34b540dd3ad1b030c57fd97269e8f6ad905a # @v1.4.1
with:
publish: yarn changeset tag
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
build-bot:
name: Build Bot
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
docker-tag: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: true
with:
images: ghcr.io/nordeck/matrix-barcamp-bot
labels: |
org.opencontainers.image.title=Matrix BarCamp Bot
org.opencontainers.image.description=A bot accompanying the BarCamp widget to support clients without support for the required widget API calls
org.opencontainers.image.vendor=Nordeck IT + Consulting GmbH
tags: |
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v3
id: dockerBuild
with:
push: ${{ secrets.GH_APP_OS_APP_ID != '' }}
context: matrix-barcamp-bot
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#platforms: linux/amd64,linux/arm64,linux/s390x
e2e:
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
browser: ['chromium', 'firefox', 'webkit']
outputs:
docker-tag: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- name: yarn install
run: yarn install --frozen-lockfile
- name: build
run: yarn build
- name: generate disclaimer
run: yarn generate-disclaimer
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build
uses: docker/build-push-action@v3
id: dockerBuild
with:
context: .
- name: Install Playwright Browsers
run: npx playwright install --with-deps ${{ matrix.browser }}
- name: Run Playwright tests
env:
IMAGE_ID: ${{ steps.dockerBuild.outputs.imageid }}
run: yarn playwright test --project=${{ matrix.browser }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report-${{ matrix.browser }}
path: playwright-report/
retention-days: 7
deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Deploy to Dev
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- build
- e2e
steps:
- name: Generate GitHub token
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: generate_token
uses: tibdex/github-app-token@021a2405c7f990db57f5eae5397423dcc554159c # @v1.7.0
with:
app_id: ${{ secrets.GH_APP_OS_APP_ID }}
private_key: ${{ secrets.GH_APP_OS_PRIVATE_KEY }}
- name: Trigger Workflow
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: 'nordeck',
repo: '${{ secrets.GITOPS_DEPLOY_REPOSITORY }}',
workflow_id: 'deployment.yml',
ref: 'main',
inputs: {
environment: '${{ secrets.GITOPS_DEPLOY_ENVIRONMENT}}',
application: 'matrix-barcamp',
tag: '${{ github.sha }}'
}
})