-
Notifications
You must be signed in to change notification settings - Fork 5
63 lines (51 loc) · 2.32 KB
/
component-tests_kitbook.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
name: Playwright Component Tests - Kitbook
on:
deployment_status
permissions:
contents: write
pull-requests: write
jobs:
run-e2e:
name: Playwright Component Tests - Kitbook
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview – kitbook'
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.37.1-jammy # https://playwright.dev/docs/ci#github-actions-via-containers - keep version in sync with installed package
steps:
- name: Allow image commit and branch name extraction
run: git config --system --add safe.directory /__w/kitbook/kitbook # --global might work instead of --system, https://github.com/actions/checkout/issues/1169
- name: Get Branch
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: '${{ github.event.deployment_status.deployment.ref }}' # ref only needed if using the deployment_status trigger (convenient with Vercel)
- name: Extract branch name # only needed if using the deployment_status trigger (convenient with Vercel)
run: echo "GITHUB_BRANCH=$(git show -s --pretty=%D HEAD | tr -s ',' '\n' | sed 's/^ //' | grep -e 'origin/' | head -1 | sed 's/\origin\///g')" >> $GITHUB_OUTPUT
id: extract_branch
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.0
- name: Install Dependencies
run: pnpm install
- name: Run Playwright Component tests
run: pnpm build && pnpm -F kitbook test:components
env:
CI: true
PLAYWRIGHT_BASE_URL: ${{ github.event.deployment_status.target_url }}
- name: Commit Changed Component Snapshots
uses: stefanzweifel/[email protected]
if: github.event.deployment_status.environment != 'Production'
with:
commit_message: '[Updated Component Snapshots]'
branch: ${{ steps.extract_branch.outputs.GITHUB_BRANCH }} # only needed if using the deployment_status trigger (convenient with Vercel)
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30