Skip to content

Commit ce30522

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

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

.github/workflows/playwright.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ on:
33
issue_comment:
44
types: [created, edited]
55
permissions:
6-
contents: read
6+
contents: write
7+
issues: write
8+
pull-requests: write
9+
statuses: write
710
jobs:
811
playwright:
912
runs-on: ubuntu-latest
@@ -27,6 +30,32 @@ jobs:
2730
run: yarn playwright install --with-deps
2831

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

0 commit comments

Comments
 (0)