Skip to content

Commit db8bcc4

Browse files
committed
Adding PR preview
1 parent 99ff3af commit db8bcc4

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

.github/workflows/docs.yml

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

0 commit comments

Comments
 (0)