update #743
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: 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 |