Add draft for Feb issue #1755
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 Site | |
on: | |
push: | |
branches: | |
- "*" | |
- "!staging.tmp" | |
tags: | |
- "*" | |
pull_request: | |
schedule: | |
- cron: "0 0 1/4 * *" # every 4 days | |
jobs: | |
build_site: | |
name: "Zola Build" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: "Download Zola" | |
run: curl -sL https://github.com/getzola/zola/releases/download/v0.16.1/zola-v0.16.1-x86_64-unknown-linux-gnu.tar.gz | tar zxv | |
- name: "Build Site" | |
run: ./zola build | |
- name: Upload Generated Site | |
uses: actions/upload-artifact@v4 | |
with: | |
name: generated_site | |
path: public | |
zola_check: | |
name: "Zola Check" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: "Download Zola" | |
run: curl -sL https://github.com/getzola/zola/releases/download/v0.16.1/zola-v0.16.1-x86_64-unknown-linux-gnu.tar.gz | tar zxv | |
- name: "Run zola check" | |
run: ./zola check | |
check_spelling: | |
name: "Check Spelling" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: curl -L https://git.io/misspell | bash | |
name: "Install misspell" | |
- run: bin/misspell -error content | |
name: "Check for common typos using `misspell`" | |
# Executes "typos ." | |
- uses: crate-ci/[email protected] | |
name: "Check for common typos using `typos`" | |
deploy_site: | |
name: "Deploy Generated Site" | |
runs-on: ubuntu-latest | |
needs: [build_site, check_spelling] | |
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'schedule') && github.repository == 'rust-osdev/homepage' | |
permissions: | |
contents: write | |
issues: write | |
steps: | |
- name: "Download Generated Site" | |
uses: actions/[email protected] | |
with: | |
name: generated_site | |
path: generated_site | |
- name: Check out gh-pages branch | |
uses: actions/checkout@v2 | |
with: | |
ref: "gh-pages" | |
path: "gh-pages" | |
- name: "Set Up Git Identity" | |
run: | | |
git config --local user.name "GitHub Actions Deploy" | |
git config --local user.email "[email protected]" | |
working-directory: "gh-pages" | |
- name: "Delete Old Content" | |
run: "rm -r ./*" | |
working-directory: "gh-pages" | |
- name: "Add New Content" | |
run: cp -r generated_site/* gh-pages | |
- name: "Commit New Content" | |
run: | | |
git add . | |
git commit --allow-empty -m "Deploy ${GITHUB_SHA} | |
Deploy of commit https://github.com/rust-osdev/homepage/commit/${GITHUB_SHA}" | |
if git show HEAD --summary | grep -P 'create mode \d+ this-month/\d{4}-\d{2}/index.html' | |
then | |
# This might do something weird if there are multiple such pages. Hopefully that should never happen. | |
new_page=$(git show HEAD --summary | grep -P 'create mode \d+ this-month/\d{4}-\d{2}/index.html' | cut -d' ' -f5) | |
echo "Detected a new monthly page:" $new_page | |
curl -s -X POST \ | |
https://api.github.com/repos/rust-osdev/homepage/issues/212/comments \ | |
-d "{\"body\":\"New issue published: [**$new_page**](https://rust-osdev.com/$new_page). Beep boop.\"}" \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" | |
fi | |
working-directory: "gh-pages" | |
- name: "Show Changes" | |
run: "git show" | |
working-directory: "gh-pages" | |
- name: "Push Changes" | |
run: "git push" | |
working-directory: "gh-pages" |