Update models nightly #3
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 models nightly | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
update_models: | |
name: Update models and create PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- name: Install Python dependencies | |
run: pip install -r requirements.txt | |
- name: Run update_models.py | |
run: python update_models.py | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git diff --exit-code || echo "There are changes." | |
echo ::set-output name=has_changes::$(if [ $? -eq 0 ]; then echo "false"; else echo "true"; fi) | |
- name: Commit and push changes | |
if: steps.check_changes.outputs.has_changes == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git add . | |
git commit -m "Update models" | |
git push | |
- name: Create Pull Request | |
if: steps.check_changes.outputs.has_changes == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Update models" | |
title: "Update models" | |
body: "This pull request updates the models nightly and creates a PR" |