Skip to content

build_and_deploy

build_and_deploy #15

name: build_and_deploy
on:
push:
branches-ignore:
- master
# edgcpp/compiler triggers this (on develop) when doc/ changes on its main
# branch, to republish https://edgcpp.org/dev/doc/.
workflow_dispatch:
# Serialize runs (replaces the CircleCI eddiewebb/queue orb).
concurrency:
group: build_and_deploy
cancel-in-progress: false
env:
# Tag of edgcpp/compiler whose documentation is published at
# https://edgcpp.org/doc/. Bump this to publish a newer release's docs.
# The documentation for its main branch is published at
# https://edgcpp.org/dev/doc/.
COMPILER_DOC_REF: '7.0'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Build compiler documentation
run: |
.github/scripts/build-compiler-docs.sh "$COMPILER_DOC_REF" doc
.github/scripts/build-compiler-docs.sh main dev/doc
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec jekyll build
deploy:
needs: test
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Build compiler documentation
run: |
.github/scripts/build-compiler-docs.sh "$COMPILER_DOC_REF" doc
.github/scripts/build-compiler-docs.sh main dev/doc
- uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
- run: bundle exec jekyll build
- name: Deploy to master
run: |
COMMIT_MESSAGE="$(git log -1 --pretty=%B)"
# Unlike the old CircleCI deploy (which preserved .circleci/ so CI
# config stayed on master), .github/ is intentionally NOT kept:
# GITHUB_TOKEN is not allowed to push workflow files, and the
# workflow ignores master anyway.
find . -maxdepth 1 ! -name '_site' ! -name '.git' -exec rm -rf {} \;
mv _site/* .
rm -r _site/
# Serve master as-is. Without this, GitHub Pages runs Jekyll over it
# again, which drops the documentation's _static/ and _sources/
# directories.
touch .nojekyll
git config --global user.name "GitHub Actions"
git config --global user.email "actions@edgcpp.org"
git add .
git commit --allow-empty -m "$COMMIT_MESSAGE"
git push -f origin HEAD:master