Skip to content

Commit 07b594c

Browse files
committed
Adding PR preview
1 parent 99ff3af commit 07b594c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,54 @@ jobs:
4848
FOLDER: "${{ env.SITE_DIR }}"
4949
BRANCH: "gh-pages"
5050
COMMIT_MESSAGE: "[CI] Publish Documentation for ${{ github.sha }}"
51+
52+
deploy_preview:
53+
env:
54+
PR_PATH: pull-${{ github.event.number }}
55+
runs-on: [ ubuntu-latest ]
56+
needs: [ build_site ]
57+
name: "Deploy preview for PR"
58+
if: github.event_name == 'pull_request'
59+
steps:
60+
- name: Comment on PR
61+
uses: hasura/[email protected]
62+
with:
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
repository: ${{ github.repository }}
65+
number: ${{ github.event.number }}
66+
id: deploy-preview
67+
message: "Starting deployment of preview ⏳..."
68+
69+
- name: Set base URL for preview
70+
run: echo "BASE_URL=https://${{ github.event.organization.name }}.github.io/${{ github.event.repository.name }}/${{ env.PR_PATH }}/" >> $GITHUB_ENV
71+
72+
- name: Checkout
73+
uses: actions/checkout@v4
74+
- name: Download generated site
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: site
78+
path: "${{ github.workspace }}/${{ env.SITE_DIR }}"
79+
- name: Deploy PR preview
80+
uses: JamesIves/[email protected]
81+
with:
82+
GITHUB_TOKEN: "${{ github.token}}"
83+
FOLDER: "${{ env.SITE_DIR }}/${{ env.PR_PATH }}"
84+
BRANCH: "gh-pages"
85+
COMMIT_MESSAGE: "[CI] Publish Preview for PR #${{ github.event.number }}"
86+
87+
- name: Update comment
88+
uses: hasura/[email protected]
89+
with:
90+
github-token: ${{ secrets.GITHUB_TOKEN }}
91+
repository: ${{ github.repository }}
92+
number: ${{ github.event.number }}
93+
id: deploy-preview
94+
message: |
95+
A preview of ${{ github.event.after }} is uploaded and can be seen here:
96+
97+
✨ ${{ env.BASE_URL }} ✨
98+
99+
Changes may take a few minutes to propagate.
100+
101+
The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/

0 commit comments

Comments
 (0)