use a simpler merge as a demo for Lecture 2 #961
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: Publish school-specific branches / site versions | |
on: push | |
# cancel any previous builds | |
concurrency: | |
group: schools-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
schools: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
school: | |
- columbia | |
- nyu | |
# https://github.com/mamba-org/setup-micromamba?tab=readme-ov-file#about-login-shells | |
defaults: | |
run: | |
shell: bash -leo pipefail {0} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: ./.github/actions/setup | |
# avoid force pushes on school branches by merging main but then only committing the processed files | |
- name: Configure Git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: Switch to school branch | |
run: git switch ${{ matrix.school }} | |
- name: Merge from base branch | |
run: git merge -s ours --no-commit --no-ff ${{github.ref_name}} | |
- name: Restore files from base branch | |
# https://stackoverflow.com/a/68636946/358804 | |
run: git restore --source ${{github.ref_name}} --worktree --staged -- . | |
- name: Commit preliminary changes | |
run: | | |
git add -A | |
git commit -m "CI: render for school" | |
# can be used for troubleshooting | |
# - name: Store merged source | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ matrix.school }}-src | |
# path: ./ | |
- name: Render for school | |
run: ./extras/scripts/school_ci.sh ${{ matrix.school }} | |
- name: Update commit | |
run: | | |
git add -A | |
git commit --amend --no-edit | |
- name: Push branch | |
run: git push origin ${{ matrix.school }} | |
if: github.ref_name == 'main' | |
- name: Store rendered HTML for link checking | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.school }} | |
path: _build/html | |
# do this as a separate job from link checking so that broken external links don't block the site build | |
check_links: | |
runs-on: ubuntu-latest | |
needs: schools | |
strategy: | |
fail-fast: false | |
matrix: | |
school: | |
- columbia | |
- nyu | |
steps: | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3" | |
- name: Install dependencies | |
run: gem install html-proofer | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.school }} | |
path: _build/html | |
- name: Check for broken links | |
run: ruby extras/scripts/broken_links.rb |