-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (81 loc) · 3.04 KB
/
wordcount.yaml
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
90
name: Nightly thesis word count
on:
schedule:
# quote due to '*'; cron-input-style string: 55' 23h DD MM day(s)
- cron: '55 23 * * 1-5'
# for testing, this lets us run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# id
nightly-word-count:
# name
name: Nightly word count
# which GH-hosted runner to use, in this case we don't really mind as long
# as its linux and `ubuntu-latest` is what GH provides. Also fairly simple
# to modify later
runs-on: ubuntu-latest
steps:
# Need some dependencies
# https://github.com/marketplace/actions/checkout
# Website is needed
# and needs a PAT to trigger the `publish` push workflow
- name: Checkout website
uses: actions/checkout@v4
with:
path: personal-website
token: ${{ secrets.WEBSITE_TOKEN }}
# also need the PhD repo
- name: Checkout phd-thesis
uses: actions/checkout@v4
with:
repository: 'CodingCellist/phd-thesis'
path: phd-thesis
ref: 'main'
token: ${{ secrets.PHD_TOKEN }}
# https://github.com/marketplace/actions/setup-python
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
personal-website/static/uploads/thesis-plot/requirements.txt
# update `pip` and install plotly+pandas
- name: Update pip, install deps
run: |
cd personal-website/static/uploads/thesis-plot/
pip install --upgrade pip
pip install -r requirements.txt
# just to be safe
cd ../../../../
# download, extract, and configure the texcount perl script
- name: Setup texcount
run: |
curl -L -o texcount.zip https://app.uio.no/ifi/texcount/download.php?file=texcount_3_2_0_41.zip
unzip texcount.zip
rm -rf Doc
mv -v texcount{.pl,}
chmod +x texcount
# add current location to the path for texcount to be available
echo "$PWD" >> $GITHUB_PATH
- name: Count the words
run: |
cd phd-thesis/latex-src
chmod +x xwcount.sh
# count the words, removing the stderr output and keeping only
# numbers, add the date it was measured, and append the resulting data
# entry to the data file
./xwcount.sh 2> /dev/null | grep -P '^\d+$' | tr -d '\n' | cat - <(echo -n ",") <(date -I) >> ../../personal-website/static/uploads/thesis-plot/wcount.csv
cd ../..
- name: Read data, make plot
run: |
cd personal-website
python static/uploads/thesis-plot/plot.py > content/en/post/writing-up-a-phd/wcount-plot.json
cd ..
- name: Add plot and push
run: |
cd personal-website
git config user.name github-actions
git config user.email [email protected]
git commit -a -m "[ generated ] Nightly thesis plot"
git push