yarn corepack #116
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: Build, test, deploy to GitHub Pages | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
workflow_dispatch: # Can run this workflow manually from the Actions tab | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
# Build using Jekyll, save GitHub Pages artifact and build artifact | |
build: | |
name: Jekyll build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Ruby # See https://www.ruby-lang.org/en/downloads/branches/ | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.2 # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Build site | |
run: bundle exec jekyll build | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: npm install xml2js front-matter | |
- name: Generate sitemap | |
run: node generate-sitemap.js | |
- name: Upload build artifact, ready for GitHub Pages deployment | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: build/ | |
- name: Upload build artifact, ready for testing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifact | |
path: build/ # or the path to your Jekyll build directory | |
# Test the build artifact | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: "yarn" | |
- name: Setup yarn using corepack | |
run: corepack enable | |
- name: Install node packages | |
run: yarn install --immutable | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifact | |
path: build/ | |
- name: Cache testing | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: cache/ | |
key: ${{ runner.os }}-testing | |
save-always: true | |
- name: Test suite | |
run: yarn run test | |
# Deploy the GitHub Pages artifact | |
deploy-github-pages: | |
name: Deploy to GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |