Build & Deploy Notices #67407
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 & Deploy Notices | |
on: | |
schedule: | |
# as often as possible during work hours Monday–Friday (UTC) | |
# (becomes complicated due to DST & the Los Angeles time zone) | |
- cron: '* 15-23 * * 1-5' | |
- cron: '* 0-2 * * 2-6' | |
# once a day otherwise | |
- cron: '8 8 * * *' | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write # write is required to commit changes | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment to GitHub Pages | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
changes: ${{ steps.commit.outputs.changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 # in order to determine changed files | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install arrow beautifulsoup4 bleach feedparser | |
- name: Create fragments directory | |
run: mkdir -p fragments/notices | |
- name: 🐞 python --version | |
run: python --version | |
- name: Build notices fragments from RSS feed | |
run: python .github/workflows/notices.py ${{ secrets.LIBCAL_RSS_NOTICES_TODAY_URL }} | |
- name: Generate fragments/notices/index.html with tree | |
run: tree -H '.' -L 1 --noreport --charset utf-8 -o fragments/notices/index.html fragments/notices | |
- name: Configure Git identity | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Commit changes | |
id: commit | |
run: echo "changed=false" >> $GITHUB_OUTPUT; | |
if [ -n "$(git ls-files --others --modified)" ]; | |
then | |
git ls-files --others --modified | xargs git add --all; | |
git commit -m "update notices fragments"; | |
git push; | |
echo "changed=true" >> $GITHUB_OUTPUT; | |
fi; | |
git log -1; | |
deploy: | |
needs: build | |
if: needs.build.outputs.changes == 'true' | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
# TODO move pages deployment to an independent workflow | |
# if other workflows ever need to publish fragments | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: 🐞 git log -1 | |
run: git log -1 | |
- uses: actions/configure-pages@v5 | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload only a specific directory | |
path: 'fragments' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |