-
Notifications
You must be signed in to change notification settings - Fork 0
Create GitHub Actions Workflow for Publishing to GitHub Pages
Tiffany Forkner edited this page Apr 2, 2025
·
3 revisions
Important
All of the files in this section should be created in the gh-pages
branch.
In the gh-pages
branch, create the file .github/workflows/publish-github-pages.yml
. This will build the site and deploy it to the github-pages
environment.
name: GitHub Pages Build and Deploy
on:
push:
branches:
- gh-pages
# ensures that currently running GitHub Pages Build and Deploy workflows are canceled if another one starts
concurrency:
group: publish-github-pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v4
with:
ref: gh-pages
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- name: Build Site
run: |
rm -rf .bundle
rm -rf Gemfile.lock
bundle install --no-deployment
bundle exec jekyll build
- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
deploy:
needs: build
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Commit the changes so far and push them to origin. If everything is set up correctly, it should start up the GitHub Pages Build and Deploy workflow automatically and deploy the site. It should look similar to this until you add some data.