-
-
Notifications
You must be signed in to change notification settings - Fork 17
90 lines (78 loc) · 2.75 KB
/
update.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
90
---
name: update
on:
schedule:
# run every day at 3am
- cron: '0 3 * * *'
workflow_dispatch:
inputs:
sleep_seconds:
description: "Enter seconds to pause between requests (default: 10)"
required: false
default: '10'
recheck_404s:
description: "Recheck 404s (default: false)"
type: boolean
required: false
default: false
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Run actions/checkout
uses: actions/checkout@v4
- name: Run actions/setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Run pip install -r requirements.txt
run: |
# Run pip install -r requirements.txt
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run python update.py (can take up to 3 hours)
# ignore syntax error on the following line
run: python update.py ${{ inputs.sleep_seconds }} ${{ inputs.recheck_404s }}
- name: Commit changes
run: |
# Commit changes to repository
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
function commit() {
printf "Found %s %s file(s)\n" "${#MAPFILE[@]}" "$1"
if ((${#MAPFILE[@]}==0)); then
return 0
fi
# create individual commit per updated manifest
commits=0
for file in "${MAPFILE[@]}"; do
if [[ "${file}" =~ bucket/.*\.json$ ]]; then
manifest=$(basename "${file}" .json)
version=$(jq -r .version <"${file}")
git add "${file}"
git commit -m "${manifest}: Update to version ${version}"
((commits++)) || true
continue
fi
if [[ ${file} =~ urls\.csv$ ]]; then
git add "${file}"
git commit -m "Update url list [ci skip]"
((commits++)) || true
continue
fi
printf "UH OH! Found unexpected changed file '%s'\n" "${file}"
done
printf "Committed %s of %s changed files\n" "${commits}" "${#MAPFILE[@]}"
return 0
}
mapfile -t < <(git diff --ignore-all-space --name-only --no-color)
commit "changed"
mapfile -t < <(git ls-files bucket/*.json --others --exclude-standard)
commit "new"
exit 0
- name: Run ad-m/github-push-action
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master