-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.41 KB
/
test.yaml
File metadata and controls
52 lines (43 loc) · 1.41 KB
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
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium firefox webkit
- name: Run tests
id: tests
run: |
if npm test; then
echo "status=passing" >> $GITHUB_OUTPUT
echo "color=brightgreen" >> $GITHUB_OUTPUT
else
echo "status=failing" >> $GITHUB_OUTPUT
echo "color=red" >> $GITHUB_OUTPUT
exit 1
fi
- name: Generate badges
if: github.ref == 'refs/heads/main'
run: |
# Create orphan branch for badges
git checkout --orphan badges || git checkout badges
git rm -rf . 2>/dev/null || true
# Create both badges
echo "{\"schemaVersion\": 1, \"label\": \"tests\", \"message\": \"${{ steps.tests.outputs.status }}\", \"color\": \"${{ steps.tests.outputs.color }}\"}" > tests.json
git config user.name github-actions
git config user.email github-actions@github.com
git add tests.json
git commit -m "Update badges"
git push origin badges --force