|
3 | 3 | issue_comment:
|
4 | 4 | types: [created, edited]
|
5 | 5 | permissions:
|
6 |
| - contents: read |
| 6 | + contents: write |
| 7 | + statuses: write |
7 | 8 | jobs:
|
8 | 9 | playwright:
|
9 | 10 | runs-on: ubuntu-latest
|
10 | 11 | if: contains(github.event.comment.html_url, '/pull/') && github.event.comment.user.login == 'netlify[bot]' && contains(github.event.comment.body, 'ready!')
|
11 | 12 | steps:
|
| 13 | + - name: Mark pending status |
| 14 | + uses: actions/github-script@v7 |
| 15 | + if: always() |
| 16 | + id: pending_status |
| 17 | + with: |
| 18 | + script: | |
| 19 | + // Get the most recent commit on the PR |
| 20 | + const commits = await github.rest.pulls.listCommits({ |
| 21 | + owner: context.issue.owner, |
| 22 | + repo: context.issue.repo, |
| 23 | + pull_number: context.issue.number, |
| 24 | + per_page: 1 |
| 25 | + }); |
| 26 | + const headCommit = commits.data[0].sha; |
| 27 | + const commitStatus = { |
| 28 | + owner: context.repo.owner, |
| 29 | + repo: context.repo.repo, |
| 30 | + sha: headCommit, |
| 31 | + state: 'pending', |
| 32 | + target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, |
| 33 | + context: 'Playwright' |
| 34 | + }; |
| 35 | + await github.rest.repos.createCommitStatus(commitStatus); |
| 36 | + return commitStatus; |
| 37 | +
|
12 | 38 | - run: git config --global core.autocrlf input
|
13 | 39 | - uses: actions/checkout@v4
|
14 | 40 | with:
|
|
27 | 53 | run: yarn playwright install --with-deps
|
28 | 54 |
|
29 | 55 | - name: Run tests
|
| 56 | + id: playwright_test |
30 | 57 | env:
|
31 | 58 | PLAYWRIGHT_TEST_BASE_URL: https://deploy-preview-${{ github.event.issue.number }}--cambria-project.netlify.app
|
32 | 59 | run: yarn playwright test
|
| 60 | + |
| 61 | + - name: Update commit status |
| 62 | + uses: actions/github-script@v7 |
| 63 | + if: always() |
| 64 | + env: |
| 65 | + COMMIT_STATUS: ${{ steps.pending_status.outputs.result }} |
| 66 | + TEST_STATUS: ${{ steps.playwright_test.outcome == 'success' && 'success' || 'failure' }} |
| 67 | + with: |
| 68 | + script: | |
| 69 | + // Get the most recent commit on the PR |
| 70 | + const commitStatus = JSON.parse(process.env.COMMIT_STATUS); |
| 71 | + commitStatus.state = process.env.TEST_STATUS; |
| 72 | + commitStatus.target_url = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; |
| 73 | + await github.rest.repos.createCommitStatus(commitStatus); |
0 commit comments