Skip to content

Commit e49a0dd

Browse files
authored
Merge branch 'main' into patch-1
2 parents 7f56d7a + 99e453a commit e49a0dd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

.github/workflows/deploy-prod.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy
22

33
on:
44
workflow_run:
5-
workflows: [build]
5+
workflows: [Build]
66
types:
77
- completed
88

@@ -11,6 +11,9 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
1313
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
1417
- name: Download pages
1518
uses: actions/download-artifact@v4
1619
with:
@@ -44,7 +47,7 @@ jobs:
4447

4548
deploy_github_pages:
4649
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'
4851
steps:
4952
- name: Checkout repository
5053
uses: actions/checkout@v3
@@ -68,21 +71,21 @@ jobs:
6871
github_token: ${{ github.token }}
6972
publish_dir: ./public
7073
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' }}/
7275

7376
- name: Update or create preview comment
74-
if: github.event_name == 'pull_request'
7577
uses: actions/github-script@v6
78+
if: github.event.workflow_run.event == 'pull_request'
7679
with:
7780
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 }};
8082
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 }};
8285
const baseUrl = `https://${owner}.github.io/${repo}/`;
8386
const previewUrl = `${baseUrl}${prNumber}/`;
8487
const body = `Preview the changes for PR #${prNumber} (${commitSha}) here: [${previewUrl}](${previewUrl})`;
85-
88+
8689
// Retrieve comments for the PR to check if the comment already exists
8790
const { data: comments } = await github.rest.issues.listComments({
8891
owner: owner,

0 commit comments

Comments
 (0)