-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (82 loc) · 2.82 KB
/
notices.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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