-
Notifications
You must be signed in to change notification settings - Fork 3
166 lines (165 loc) · 4.36 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
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
name: CI
on:
pull_request:
merge_group:
push:
branches:
- master
- renovate/*
tags:
- "v*"
permissions:
packages: write
concurrency:
group: tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
cancel-in-progress: true
jobs:
environments:
name: "Environments"
needs:
- publish
runs-on: ubuntu-20.04
outputs:
environments: ${{ steps.matches.outputs.environments }}
steps:
- uses: wreality/[email protected]
with:
tags: ${{ needs.publish.outputs.tags}}
token: ${{ secrets.REPO_TOKEN }}
id: matches
client-unit-test:
name: "Client / Unit Test"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
cache-dependency-path: client/yarn.lock
- run: cd client && yarn install
- run: cd client && yarn test:unit:ci
build-images:
name: "Build"
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.build-image.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/build-image
id: build-image
name: Build Image
backend-unit-test:
name: Backend / Unit Test
needs: [build-images]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Start Stack
uses: ./.github/actions/start-stack
with:
version: ${{ needs.build-images.outputs.version }}
- run: docker compose exec -T phpfpm ./artisan test
name: Run Unit Test
- run: docker compose down
name: Stop Stack
e2e:
name: "E2E Test"
needs: [build-images]
uses: ./.github/workflows/do-test-e2e.yml
secrets: inherit
with:
version: ${{ needs.build-images.outputs.version }}
lint-php:
name: PHP Lint
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
- name: Install dependencies
run: composer install
- name: Check PHP
run: composer lint
lint-js:
name: JS Lint
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./client
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
cache-dependency-path: client/yarn.lock
- name: Install dependencies
run: yarn
- name: Check JS
run: yarn lint
lint-md:
name: MD Lint
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install
- name: Check MD
run: yarn lint:md
publish:
name: "Publish (master branch only)"
runs-on: ubuntu-20.04
needs: [backend-unit-test, client-unit-test, e2e]
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
outputs:
tags: ${{ steps.build-image.outputs.tags }}
steps:
- uses: actions/checkout@v3
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/build-image
id: build-image
with:
target: release
deployments:
runs-on: ubuntu-20.04
needs:
- environments
- publish
name: "Deploy"
environment:
name: ${{ matrix.environment }}
url: ${{ vars.URL }}
strategy:
fail-fast: false
matrix:
environment: ${{ fromJson(needs.environments.outputs.environments) }}
steps:
- uses: actions/checkout@v3
- run: |
curl -X POST -H 'Authorization: Bearer ${{ secrets.DEPLOY_KEY}}' ${{ secrets.DEPLOY_URL }}
shell: bash