@@ -2,7 +2,7 @@ name: Deploy
2
2
3
3
on :
4
4
workflow_run :
5
- workflows : [build ]
5
+ workflows : [Build ]
6
6
types :
7
7
- completed
8
8
11
11
runs-on : ubuntu-latest
12
12
if : github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
13
13
steps :
14
+ - name : Checkout repository
15
+ uses : actions/checkout@v3
16
+
14
17
- name : Download pages
15
18
uses : actions/download-artifact@v4
16
19
with :
44
47
45
48
deploy_github_pages :
46
49
runs-on : ubuntu-latest
47
- if : github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
50
+ if : github.event.workflow_run.conclusion == 'success'
48
51
steps :
49
52
- name : Checkout repository
50
53
uses : actions/checkout@v3
@@ -68,21 +71,21 @@ jobs:
68
71
github_token : ${{ github.token }}
69
72
publish_dir : ./public
70
73
publish_branch : gh-pages
71
- destination_dir : ${{ github.event.pull_request .number || 'main' }}/
74
+ destination_dir : ${{ github.event.workflow_run.pull_requests[0] .number || 'main' }}/
72
75
73
76
- name : Update or create preview comment
74
- if : github.event_name == 'pull_request'
75
77
uses : actions/github-script@v6
78
+ if : github.event.workflow_run.event == 'pull_request'
76
79
with :
77
80
script : |
78
- const prNumber = ${{ github.event.pull_request.number }};
79
- const repo = context.repo.repo;
81
+ const prNumber = ${{ github.event.workflow_run.pull_requests[0].number }};
80
82
const owner = context.repo.owner;
81
- const commitSha = context.payload.pull_request.head.sha;
83
+ const repo = context.repo.repo;
84
+ const commitSha = ${{ github.event.workflow_run.head_sha }};
82
85
const baseUrl = `https://${owner}.github.io/${repo}/`;
83
86
const previewUrl = `${baseUrl}${prNumber}/`;
84
87
const body = `Preview the changes for PR #${prNumber} (${commitSha}) here: [${previewUrl}](${previewUrl})`;
85
-
88
+
86
89
// Retrieve comments for the PR to check if the comment already exists
87
90
const { data: comments } = await github.rest.issues.listComments({
88
91
owner: owner,
0 commit comments