forked from dso-toolkit/dso-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (91 loc) · 3.39 KB
/
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
name: CI
on: [push]
jobs:
CI:
name: lint, build, test, deploy
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
name: Log in to GitHub Container Registry
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'push') {
const [branch, type] = context.ref.split('/').reverse();
if (type === 'heads' && branch.lastIndexOf('#') === 0) {
core.exportVariable('DT_REF', branch.replace(/#/, '_'));
}
else if (type === 'heads' && branch === 'master') {
core.exportVariable('DT_REF', 'master');
}
else if (type === 'tags' && branch[0] === 'v') {
core.exportVariable('DT_REF', branch.substring(1));
core.exportVariable('DT_DIST_TAG', 'latest');
}
}
- name: Output DT_REF
run: echo $DT_REF;
- uses: docker/build-push-action@v5
name: Build and push Docker image
with:
push: true
tags: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
context: .
cache-from: |
ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
cache-to: type=inline
build-args: |
CI
DT_REF
- name: "Prepare Cypress Parallel weights file"
run: mkdir --verbose --parents ${{ env.GITHUB_WORKSPACE }}/storybook/cypress-parallel
- name: "Cache: Cypress Parallel weights file"
id: cypress-parallel-weights-file-cache
uses: actions/cache@v4
with:
key: weights-file
path: ${{ env.GITHUB_WORKSPACE }}/storybook/cypress-parallel/parallel-weights.json
- name: e2e tests
uses: addnab/docker-run-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
options: --env CI
--env DT_REF
--volume ${{ env.GITHUB_WORKSPACE }}/storybook/cypress-parallel:/usr/src/app/storybook/cypress-parallel
run: yarn e2e
- uses: addnab/docker-run-action@v3
name: Deploy
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
options: --env CI
--env DT_REF
--env DT_DIST_TAG
--env DT_PRIVATE_KEY_BASE64
--env DT_DEPLOY_HOST
--env DT_DEPLOY_PORT
--env DT_DEPLOY_USER
--env DT_DEPLOY_ROOT
--env DT_DEPLOY_NPM_TOKEN
--env GITHUB_TOKEN
run: bash deploy.sh
env:
DT_PRIVATE_KEY_BASE64: ${{ secrets.DT_PRIVATE_KEY_BASE64 }}
DT_DEPLOY_HOST: ${{ secrets.DT_DEPLOY_HOST }}
DT_DEPLOY_PORT: ${{ secrets.DT_DEPLOY_PORT }}
DT_DEPLOY_USER: ${{ secrets.DT_DEPLOY_USER }}
DT_DEPLOY_ROOT: ${{ secrets.DT_DEPLOY_ROOT }}
DT_DEPLOY_NPM_TOKEN: ${{ secrets.DT_DEPLOY_NPM_TOKEN }}