42 lines (37 loc) · 1.37 KB
/
fetch_webmentions.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
name: Fetch webmentions
on:
schedule:
- cron: "0 5 * * *"
workflow_dispatch:
jobs:
fetch_webmentions:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
# https://github.com/orgs/community/discussions/25702
# GITHUB_TOKEN does trigger a Netlify deploy
# Will need to switch to PAT if switching to GitHub deploy
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Fetch webmentions
env:
BASE_URL: ${{ secrets.BASE_URL }}
SHORT_URL: ${{ secrets.SHORT_URL }}
WEBMENTION_IO_TOKEN: ${{ secrets.WEBMENTION_IO_TOKEN }}
run: node ./plugins/fetch_webmentions.js
- name: Commit webmentions
id: wm_commit
run: |
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git add wm
# https://stackoverflow.com/a/3162492
count=($(git diff --cached --numstat | wc -l))
count=$((count-1)) # Subtract 1 since this would include cache file
# https://stackoverflow.com/a/40255467
git diff --quiet && git diff --staged --quiet || (git commit -am "webmentions: adding ($count) webmentions"; git push;)