Content for the solution pattern #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docs | |
on: | |
push: | |
branches: | |
- master | |
- main | |
pull_request: | |
branches: | |
- '*' | |
env: | |
SITE_DIR: "gh-pages" | |
jobs: | |
build_site: | |
name: "Build site with Antora" | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: "Generate site using antora site action" | |
uses: kameshsampath/antora-site-action@master | |
with: | |
antora_playbook: site.yml | |
- name: "Upload generated site" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: "${{ github.workspace }}/${{ env.SITE_DIR }}" | |
deploy_site: | |
runs-on: [ubuntu-latest] | |
needs: [build_site] | |
name: "Deploy GitHub Pages" | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download generated site | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: "${{ github.workspace }}/${{ env.SITE_DIR }}" | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/[email protected] | |
with: | |
# ACCESS_TOKEN: # optional | |
GITHUB_TOKEN: "${{ github.token }}" | |
FOLDER: "${{ env.SITE_DIR }}" | |
BRANCH: "gh-pages" | |
COMMIT_MESSAGE: "[CI] Publish Documentation for ${{ github.sha }}" | |
deploy_preview: | |
env: | |
PR_PATH: pull-${{ github.event.number }} | |
runs-on: [ ubuntu-latest ] | |
needs: [ build_site ] | |
name: "Deploy preview for PR" | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Comment on PR | |
uses: hasura/[email protected] | |
with: | |
github-token: ${{ secrets.GHPAGES_PREVIEW_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "Starting deployment of preview ⏳..." | |
- name: Set base URL for preview | |
run: echo "BASE_URL=https://${{ github.event.organization.name }}.github.io/${{ github.event.repository.name }}/${{ env.PR_PATH }}/" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download generated site | |
uses: actions/download-artifact@v4 | |
with: | |
name: site | |
path: "${{ github.workspace }}/${{ env.SITE_DIR }}" | |
- name: Deploy PR preview | |
uses: JamesIves/[email protected] | |
with: | |
GITHUB_TOKEN: "${{ github.token }}" | |
FOLDER: "${{ env.SITE_DIR }}/${{ env.PR_PATH }}" | |
BRANCH: "gh-pages" | |
COMMIT_MESSAGE: "[CI] Publish Preview for PR #${{ github.event.number }}" | |
- name: Update comment | |
uses: hasura/[email protected] | |
with: | |
github-token: ${{ secrets.GHPAGES_PREVIEW_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: | | |
A preview of ${{ github.event.after }} is uploaded and can be seen here: | |
✨ ${{ env.BASE_URL }} ✨ | |
Changes may take a few minutes to propagate. | |
The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/ |