Monthly Update FileID #4
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: Monthly Update FileID | |
on: | |
schedule: | |
- cron: '0 0 6 * *' | |
workflow_dispatch: | |
jobs: | |
update-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
pip install bs4 | |
- name: Run update_fileid.py | |
run: python tools/update_fileid.py | |
- name: Patch version in setup.py | |
run: | | |
python -c "import re; \ | |
content = open('setup.py').read(); \ | |
version = re.search(r\"version='([0-9]+\.[0-9]+\.[0-9]+)'\", content); \ | |
major, minor, patch = version.group(1).split('.'); \ | |
patch = str(int(patch) + 1); \ | |
new_version = f\"version='{major}.{minor}.{patch}'\"; \ | |
updated_content = re.sub(r\"version='[0-9]+\.[0-9]+\.[0-9]+'\", new_version, content); \ | |
open('setup.py', 'w').write(updated_content)" | |
- name: Commit changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m 'Monthly update: file_id.json' || echo "No changes to commit." | |
- name: Push repository | |
run: git push |