Skip to content

Commit

Permalink
Update Actions workflows to support deploying to GitHub Pages. (#9)
Browse files Browse the repository at this point in the history
* Add artifact upload to site build.

When the build was triggered by a push to the main branch upload the
generated output as a GitHub Actions artifact in order to facilitate
deployment.

* Add GitHub Pages deployment actions.

Deploy uploaded artifacts to GitHub Pages.
  • Loading branch information
nuclearsandwich authored Aug 20, 2024
1 parent eb0e227 commit f5d3c53
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
name: CI
on:
push:
branches: ["main"]
Expand All @@ -12,4 +14,9 @@ jobs:
- uses: earthly/actions-setup@v1
- name: nanoc compile
run: |
earthly --ci +build
earthly --output --ci +build
- name: Upload for GitHub Pages
if: ${{ github.event_name == 'push' }}
uses: actions/upload-pages-artifact@v3
with:
path: output
33 changes: 33 additions & 0 deletions .github/workflows/pages-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Deploy to GitHub Pages
on:
# NOTE: As of 2024-08-15, this event will only trigger a workflow run if
# the workflow file is on the default branch.
# This is our desired behavior but if this default ever changes we may need
# to add additional guard clauses to make sure we are only deploying
# artifacts from the main branch.
#
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: ['CI']
types: ['completed']

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
permissions:
contents: read
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: ${{ github_event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit f5d3c53

Please sign in to comment.