Adding the post-page-artifact job #1365
Workflow file for this run
This file contains 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: website | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
release: | |
types: [published] | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
page_artifact_id: ${{ steps.upload.outputs.artifact_id }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: quarto-dev/quarto-actions/setup@v2 | |
# Setting up the environment | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Install dependencies with Poetry | |
run: poetry install --with docs | |
- name: Render documentation index from README | |
run: | | |
cp README.md docs/source/index.md | |
# Building | |
- name: Build HTML using Poetry | |
run: | | |
cd docs | |
poetry run make tutorials_clean | |
poetry run make html | |
# Upload | |
- name: Upload artifacts | |
uses: actions/upload-pages-artifact@v3 | |
id: upload | |
with: | |
name: github-pages | |
retention-days: 7 | |
path: docs/build/html/ | |
deploy: | |
# Deploy to the github-pages environment | |
# but not on PRs | |
if: ${{ github.event_name != 'pull_request' }} | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: build | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
artifact_name: github-pages | |
preview: true | |
post-page-artifact: | |
if: ${{ github.event_name == 'pull_request' }} | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Post comment preview | |
uses: CDCgov/cfa-actions/post-artifact@v1.0.0 | |
with: | |
artifact-name: github-pages | |
gh-token: ${{ secrets.GITHUB_TOKEN}} |