-
Notifications
You must be signed in to change notification settings - Fork 42
71 lines (65 loc) · 2.58 KB
/
Copy pathplaywright-comment.yml
File metadata and controls
71 lines (65 loc) · 2.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Comment on Playwright Test Results
on:
workflow_run:
workflows: ['Playwright Tests']
types:
- completed
jobs:
comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
steps:
- name: Download workflow artifact
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "playwright-report"
})[0];
if (matchArtifact) {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/playwright-report.zip`, Buffer.from(download.data));
}
- name: Get PR number
uses: actions/github-script@v7
id: get-pr-number
with:
script: |
if (context.payload.workflow_run.event === 'pull_request') {
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.payload.workflow_run.head_repository.owner.login}:${context.payload.workflow_run.head_branch}`,
});
if (pullRequests.length > 0) {
return pullRequests[0].number;
}
}
return null;
result-encoding: string
- name: Comment on PR
if: steps.get-pr-number.outputs.result != 'null'
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.get-pr-number.outputs.result }}
message: |
### 🎭 Playwright tests failed
The Playwright tests failed on this PR. Please check the test results and fix any issues.
📊 [View full test report](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }})
github-token: ${{ secrets.GITHUB_TOKEN }}
mode: upsert
create-if-not-exists: true