Skip to content

Commit 43786f9

Browse files
committed
add workflow_dispatch for running pr previews
Signed-off-by: Aritra Dey <[email protected]>
1 parent a1ad3a4 commit 43786f9

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

.github/workflows/publish-docs.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ on:
55
branches: [master]
66
pull_request:
77
branches: [master]
8+
workflow_dispatch:
9+
inputs:
10+
pr_number:
11+
description: 'PR number to deploy preview for'
12+
required: true
13+
type: number
14+
run_id:
15+
description: 'Run ID of the build workflow (from the PR checks)'
16+
required: true
17+
type: string
818

919
permissions:
1020
contents: write
@@ -13,7 +23,6 @@ permissions:
1323
jobs:
1424
build:
1525
runs-on: ubuntu-latest
16-
1726
steps:
1827
- name: Checkout
1928
uses: actions/checkout@v4
@@ -36,43 +45,46 @@ jobs:
3645
path: build/
3746

3847
deploy-pr-preview:
39-
# Runs ONLY for PRs
40-
if: ${{ github.event_name == 'pull_request' }}
48+
if: ${{ github.event_name == 'workflow_dispatch' }}
4149
runs-on: ubuntu-latest
42-
needs: build
43-
4450
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
4554
- name: Download build artifact
4655
uses: actions/download-artifact@v4
4756
with:
4857
name: site
4958
path: site
59+
run-id: ${{ inputs.run_id }}
60+
github-token: ${{ secrets.GITHUB_TOKEN }}
5061

5162
- name: Deploy PR Preview
5263
uses: JamesIves/github-pages-deploy-action@v4
5364
with:
5465
branch: gh-pages-pr-previews
5566
folder: site
56-
target-folder: pr-${{ github.event.pull_request.number }}
57-
workspace: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
67+
target-folder: pr-${{ inputs.pr_number }}
5868

5969
- name: Comment Preview URL
6070
uses: marocchino/sticky-pull-request-comment@v2
6171
with:
6272
recreate: true
73+
number: ${{ inputs.pr_number }}
6374
message: |
6475
🚀 **Preview Ready!**
6576
Your docs preview for this PR is available here:
6677
67-
**https://pecanproject.github.io/pr-${{ github.event.pull_request.number }}/**
78+
**https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ inputs.pr_number }}/**
6879
6980
deploy-production:
70-
# Runs ONLY on push to master
7181
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
7282
runs-on: ubuntu-latest
7383
needs: build
74-
7584
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
7688
- name: Download build artifact
7789
uses: actions/download-artifact@v4
7890
with:

0 commit comments

Comments
 (0)