Skip to content

Commit 137ef36

Browse files
committed
Set commit status on Playwright failure
1 parent 09d708e commit 137ef36

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/playwright.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
types: [created, edited]
55
permissions:
66
contents: read
7+
checks: write
8+
pull-requests: read
79
jobs:
810
playwright:
911
runs-on: ubuntu-latest
@@ -27,6 +29,32 @@ jobs:
2729
run: yarn playwright install --with-deps
2830

2931
- name: Run tests
32+
id: playwright_test
3033
env:
3134
PLAYWRIGHT_TEST_BASE_URL: https://deploy-preview-${{ github.event.issue.number }}--cambria-project.netlify.app
35+
continue-on-error: true
3236
run: yarn playwright test
37+
38+
- name: Update commit status
39+
uses: actions/github-script@v7
40+
if: always()
41+
env:
42+
TEST_STATUS: ${{ steps.playwright_test.outcome == 'success' && 'success' || 'failure' }}
43+
with:
44+
script: |
45+
// Get the most recent commit on the PR
46+
const commits = await github.rest.pulls.listCommits({
47+
owner: context.issue.owner,
48+
repo: context.issue.repo,
49+
pull_number: context.issue.number,
50+
per_page: 1
51+
});
52+
const headCommit = commits[0].sha;
53+
await github.rest.repos.createCommitStatus({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
sha: headCommit,
57+
state: process.env.TEST_STATUS,
58+
target_url: 'https://deploy-preview-' + context.issue.number + '--cambria-project.netlify.app',
59+
context: 'Playwright'
60+
});

0 commit comments

Comments
 (0)