Merge pull request #691 from co-cddo/dependabot/github_actions/action… #3559
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
--- | |
on: | |
pull_request: | |
push: | |
branches-ignore: | |
- gh-pages | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 | |
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 | |
with: | |
bundler-cache: true | |
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d | |
with: | |
node-version: '16' | |
- name: Cache node modules | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: npm-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ runner.os }}-build-${{ env.cache-name }}- | |
npm-${{ runner.os }}-build- | |
npm- | |
- name: Install NPM dependencies | |
run: npm install | |
- name: Test | |
run: bundle exec rspec | |
- name: Lint | |
run: bundle exec rubocop --parallel | |
- name: Validate schema | |
run: bundle exec rake schema | |
- name: Build | |
run: bundle exec rake build | |
- name: Upload built site | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce | |
with: | |
name: site | |
path: build | |
retention-days: 1 | |
htmlproofer: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 | |
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 | |
with: | |
bundler-cache: true | |
- name: Download built site | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a | |
with: | |
name: site | |
path: build | |
- name: Test built site | |
run: bundle exec rake htmlproofer | |
publish: | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: build | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 | |
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 | |
with: | |
bundler-cache: true | |
- name: Download built site | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a | |
with: | |
name: site | |
path: build | |
# Checkout stripped-down gh-pages branch to a subdirectory, for publishing | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 | |
with: | |
ref: gh-pages | |
path: tmp/publish | |
- name: Publish | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "github-actions" | |
bundle exec rake publish CLONED_GH_PAGES_DIR="tmp/publish" |