-
Notifications
You must be signed in to change notification settings - Fork 319
141 lines (131 loc) · 3.88 KB
/
main.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
name: WebUI
on:
push:
branches:
- master
paths-ignore:
- 'tests/**'
pull_request:
branches:
- '**'
paths-ignore:
- 'tests/**'
jobs:
install:
name: Checkout and Install
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
check-files:
name: Check if translations only were changed
runs-on: ubuntu-latest
outputs:
translations-only: ${{ steps.determine-changes.outputs.translations-only }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Determine if only translations were changed
id: determine-changes
run: |
CHANGED_FILES=$(git diff --name-only HEAD~1 ${{ github.sha }})
echo "Changed files:"
echo "$CHANGED_FILES"
TRANSLATIONS_ONLY="true"
for file in $CHANGED_FILES; do
if [[ "$file" != "src/assets/i18n/"* ]]; then
TRANSLATIONS_ONLY="false"
break
fi
done
echo "::set-output name=translations-only::$TRANSLATIONS_ONLY"
build:
name: Build
needs: [check-files, install]
runs-on: ubuntu-latest
if: ${{ needs.check-files.outputs.translations-only == 'false' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
- name: Build
run: yarn build:prod:aot
lint:
name: Validate code style
needs: [check-files, install]
runs-on: ubuntu-latest
if: ${{ needs.check-files.outputs.translations-only == 'false' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
- name: Generate default environment file
run: yarn run check-env
- name: Build
run: yarn lint
lint-translations:
name: Validate translation strings
needs: [install]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
- name: Validate
run: yarn run validate-translations
test:
name: Run tests
needs: [check-files, install]
runs-on: ubuntu-latest
if: ${{ needs.check-files.outputs.translations-only == 'false' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
- name: Run tests
run: yarn test:pr
- if: ${{ env.CODECOV_TOKEN }}
name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
name: webui
token: ${{ env.CODECOV_TOKEN }}
fail_ci_if_error: true
resort-strings:
name: Resort Strings and Commit if only translations were added
needs: [check-files, install]
runs-on: ubuntu-latest
if: ${{ needs.check-files.outputs.translations-only == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 1
- name: Install
uses: ./.github/actions/prepare
- name: Extract Messages
run: yarn run extract
- name: Validate Translations
run: yarn run validate-translations
- name: Commit and Push Changes
run: |
git config --global user.name 'BugClerk'
git config --global user.email '[email protected]'
git pull origin ${{ github.head_ref }} --no-edit
git add src/assets/i18n
if ! git diff --quiet --cached; then
git commit -m "NAS-XXXXXX: Auto resort translation strings"
git push origin ${{ github.head_ref }}
else
echo "No changes to commit."
fi