-
Notifications
You must be signed in to change notification settings - Fork 6
177 lines (161 loc) · 5.54 KB
/
docker.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
name: Docker
on:
push:
branches:
- '*'
tags:
- '*'
merge_group:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docker:
runs-on: ubuntu-24.04
outputs:
docker_tag: ${{ steps.meta.outputs.version }}
strategy:
matrix:
package:
[
{ name: 'app-api', dockerfile: './containers/generic-app/Dockerfile' },
{ name: 'web-main', dockerfile: './containers/generic-web/Dockerfile' },
{ name: 'app-mock-gameserver', dockerfile: './containers/generic-app/Dockerfile' },
{ name: 'app-connector', dockerfile: './containers/generic-app/Dockerfile' },
]
steps:
- name: Apply nf_conntrack_tcp_be_liberal kernel change
run: |
sudo sh -c "echo 1 > /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal"
- name: Checkout code
uses: actions/checkout@v4
- name: Repo metadata
id: repo
uses: actions/github-script@v7
with:
script: |
const repo = await github.rest.repos.get(context.repo)
return repo.data
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.package.name }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Get Git commit timestamps
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.package.name }}:latest
cache-to: type=inline
sbom: true
file: ${{ matrix.package.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PACKAGE=${{ matrix.package.name }}
TAKARO_VERSION=${{ steps.meta.outputs.version }}
TAKARO_COMMIT=${{ github.sha }}
TAKARO_BUILD_DATE=${{ env.TIMESTAMP }}
env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
node-ci:
needs: [docker]
timeout-minutes: 60
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [20]
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.TAKARO_CI_APP_ID }}
private_key: ${{ secrets.TAKARO_CI_APP_PRIV_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: ./scripts/dev-init.sh
- run: npm run test:style
- name: Integration tests
run: npx zx scripts/integration-tests.mjs
env:
DOCKER_TAG: ${{ needs.docker.outputs.docker_tag }}
TEST_LOGGING_LEVEL: debug
LOGGING_LEVEL: debug
NODE_ENV: test
TRACING_ENABLED: false
GRAFANA_CLOUD_TEMPO_URL: ${{ secrets.GRAFANA_CLOUD_TEMPO_URL }}
GRAFANA_CLOUD_API_USER: ${{ secrets.GRAFANA_CLOUD_API_USER }}
GRAFANA_CLOUD_API_KEY: ${{ secrets.GRAFANA_CLOUD_API_KEY }}
- name: Commit and push if changed
if: github.ref == 'refs/heads/development'
run: |
# Check if there are any changes
if git diff --quiet; then
echo "No changes to commit."
else
# Check if the last commit was made by the CI bot
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
if [ "$LAST_AUTHOR" = "takaro-ci-bot[bot]" ]; then
echo "Last commit was made by the CI bot. Skipping commit."
else
git config --global user.name 'takaro-ci-bot[bot]'
git config --global user.email '138661031+takaro-ci-bot[bot]@users.noreply.github.com'
git commit -am "chore: generate api client"
git push
fi
fi
- uses: actions/upload-artifact@v4
if: always()
with:
name: integrationTests
path: reports
retention-days: 30
e2e:
needs: [docker]
timeout-minutes: 60
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: ./scripts/dev-init.sh
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Integration tests e2e
run: npx zx scripts/integration-tests.mjs
env:
DOCKER_TAG: ${{ needs.docker.outputs.docker_tag }}
IS_E2E: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: e2e
path: reports
retention-days: 30