Skip to content

Commit 11cf61e

Browse files
committed
Adding PR preview
1 parent 99ff3af commit 11cf61e

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

.github/workflows/docs.yml

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

0 commit comments

Comments
 (0)