-
Notifications
You must be signed in to change notification settings - Fork 3
158 lines (145 loc) · 4.69 KB
/
build.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
name: build
on:
push:
branches:
- 'main'
- 'release-*'
paths-ignore:
- 'e2e/**'
- 'playwright.config.ts'
- '.github/workflows/run_e2e_tests.yml'
pull_request:
types:
- opened
- reopened
- ready_for_review
- synchronize
# paths-ignore:
# - 'e2e/**'
# - 'playwright.config.ts'
# - '.github/workflows/run_e2e_tests.yml'
workflow_dispatch:
env:
NODE_ENV: production
AVA_FORCE_CI: 'not-ci'
HUSKY: 0
REGISTRY: ghcr.io
IMAGE_REPO: ${{ github.repository }}
GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
jobs:
test:
runs-on: ubuntu-24.04
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || !github.event.pull_request.draft }}
steps:
- run: sudo apt-get update && sudo apt-get install -y gettext
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm run i18n:gettext-sync
- shell: bash
run: |
status=$(git status --porcelain)
if [ -n "$status" ]; then
echo "You have gettext translation files unsynced. Please run i18n:gettext-sync locally."
exit 1
else
echo "Translations are synced."
fi
- run: pnpm i --prod=false
- run: pnpm run postinstall
- run: pnpm run lint
- run: pnpm run typecheck
- run: env NODE_ENV=test pnpm run coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
build:
runs-on: ubuntu-24.04
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm i --prod=false
- name: vite build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: pnpm run build
- name: Display structure of builded files
run: ls -R
working-directory: .
- name: Make artifact folder for dist (workaround for actions/upload-artifact@v4 bug)
run: mkdir ./_artifact && mv ./dist ./_artifact
working-directory: .
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: ./_artifact
publish:
needs: build
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (startsWith(github.ref_name, 'release') || github.ref_name == 'main')) }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}
- name: Display structure of downloaded files
run: ls -R
working-directory: .
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}
tags: |
type=raw,value=${{ github.ref_name }}.{{sha}}.${{ github.run_attempt }},enable=${{github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
type=raw,value=${{ github.head_ref }}.{{sha}}.${{ github.run_attempt }},enable=${{github.event_name == 'pull_request'}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}