|
2 | 2 | name: Pull Request Comments
|
3 | 3 |
|
4 | 4 | on:
|
5 |
| - pull_request: |
6 |
| - types: [ 'opened' ] |
7 |
| - pull_request_target: |
8 |
| - types: [ 'opened' ] |
9 | 5 | workflow_run:
|
10 | 6 | workflows:
|
11 | 7 | - TestBuildProcesses
|
12 | 8 | types:
|
13 | 9 | - completed
|
14 | 10 |
|
15 |
| -# Disable permissions for all available scopes by default. |
16 |
| -# Any needed permissions should be configured at the job level. |
17 |
| -permissions: {} |
18 |
| - |
19 | 11 | jobs:
|
20 |
| - # Leaves a comment on a pull request with a link to test the changes in a WordPress Playground instance. |
21 |
| - playground-details: |
22 |
| - name: Comment on a pull request with Playground details |
| 12 | + test-job: |
| 13 | + name: Test Step |
23 | 14 | runs-on: ubuntu-latest
|
24 |
| - permissions: |
25 |
| - issues: write |
26 |
| - pull-requests: write |
27 | 15 | steps:
|
28 |
| - - name: 'Download artifact' |
29 |
| - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 |
30 |
| - with: |
31 |
| - script: | |
32 |
| - var artifacts = await github.actions.listWorkflowRunArtifacts({ |
33 |
| - owner: context.repo.owner, |
34 |
| - repo: context.repo.repo, |
35 |
| - run_id: ${{github.event.workflow_run.id }}, |
36 |
| - }); |
37 |
| - /* |
38 |
| - github.repository: ${{github.repository}} |
39 |
| - github.event_name: ${{github.event_name}} |
40 |
| - github.event.workflow_run.event: ${{github.event.workflow_run.event}} |
41 |
| - github.event.workflow_run.conclusion: ${{github.event.workflow_run.conclusion}} |
42 |
| - */ |
43 |
| - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
44 |
| - return artifact.name == "pr" |
45 |
| - })[0]; |
46 |
| - var download = await github.actions.downloadArtifact({ |
47 |
| - owner: context.repo.owner, |
48 |
| - repo: context.repo.repo, |
49 |
| - artifact_id: matchArtifact.id, |
50 |
| - archive_format: 'zip', |
51 |
| - }); |
52 |
| - var fs = require('fs'); |
53 |
| - fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); |
54 |
| -
|
55 |
| - - run: unzip pr.zip |
56 |
| - |
57 |
| - - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 |
58 |
| - with: |
59 |
| - script: | |
60 |
| - const issue_number = Number(fs.readFileSync('./NR')); |
61 |
| -
|
62 |
| - // Comments are only added after the first successful build. Check for the presence of a comment and bail early. |
63 |
| - const commentInfo = { |
64 |
| - owner: context.repo.owner, |
65 |
| - repo: context.repo.repo, |
66 |
| - issue_number, |
67 |
| - }; |
68 |
| -
|
69 |
| - const comments = ( await github.rest.issues.listComments( commentInfo ) ).data; |
70 |
| -
|
71 |
| - for ( const currentComment of comments ) { |
72 |
| - if ( currentComment.user.type === 'Bot' && currentComment.body.includes( 'Test using WordPress Playground' ) ) { |
73 |
| - // return; |
74 |
| - } |
75 |
| - }; |
76 |
| -
|
77 |
| - // No comment was found. Create one. |
78 |
| - commentInfo.body = `## Test using WordPress Playground |
79 |
| - The changes in this pull request can previewed and tested using a [WordPress Playground](https://developer.wordpress.org/playground/) instance. |
80 |
| - |
81 |
| - github.repository: ${{github.repository}} |
82 |
| - github.event_name: ${{github.event_name}} |
83 |
| - github.event.workflow_run.event: ${{github.event.workflow_run.event}} |
84 |
| - github.event.workflow_run.conclusion: ${{github.event.workflow_run.conclusion}} |
85 |
| -
|
86 |
| - [WordPress Playground](https://developer.wordpress.org/playground/) is an experimental project that creates a full WordPress instance entirely within the browser. |
87 |
| -
|
88 |
| - ### Some things to be aware of |
89 |
| - - The Plugin and Theme Directories cannot be accessed within Playground. |
90 |
| - - All changes will be lost when closing a tab with a Playground instance. |
91 |
| - - All changes will be lost when refreshing the page. |
92 |
| - - A fresh instance is created each time the link below is clicked. |
93 |
| - - Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, |
94 |
| - it's possible that the most recent build failed, or has not completed. Check the [list of workflow runs to be sure](https://github.com/WordPress/wordpress-develop/actions/workflows/wordpress-playground.yml). |
95 |
| -
|
96 |
| - For more details about these limitations and more, check out the [Limitations page](https://wordpress.github.io/wordpress-playground/limitations/) in the WordPress Playground documentation. |
97 |
| -
|
98 |
| - [Test this pull request with WordPress Playground](https://playground.wordpress.net/wordpress.html?pr=${{ github.event.number }}). |
99 |
| - `; |
100 |
| -
|
101 |
| - github.rest.issues.createComment( commentInfo ); |
| 16 | + - run: env |
0 commit comments