.github/workflows/update.yaml #306
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
on: | |
schedule: | |
# Every day after globe_history has been uploaded | |
- cron: '21 5 * * *' | |
# But also on push | |
push: | |
branches: | |
- main | |
jobs: | |
update-db: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Update database | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -ex | |
# We are idempotent | |
# We try not to exit with an error code | |
# We push if the files have changed, otherwise we do not | |
# Install dependencies | |
sudo apt-get -y install python3-pip python3-dev | |
pip3 install --no-cache-dir -r requirements.txt | |
# Run the script that affects RELEASES.md and PREFERRED_RELEASES.txt | |
python3 update-releases.py | |
# Now we try adding them, if they have changed | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add RELEASES.md PREFERRED_RELEASES.txt README.md | |
# Have we actually changed anything? | |
if ! git diff-index --quiet HEAD --; then | |
# We have changed something, so we commit and push | |
git commit -m "Update RELEASES.md and PREFERRED_RELEASES.txt" | |
git push | |
fi |