update-badge-html #385
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-badge-html | |
# Based on: | |
# https://www.python-engineer.com/posts/run-python-github-actions/ | |
on: | |
# Schedule daily updates | |
schedule: [{cron: "0 0 * * *"}] | |
# (optional) Run workflow manually | |
workflow_dispatch: | |
# (optional) Run workflow when pushing on master/main | |
push: {branches: ["master", "main"]} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: checkout repo content | |
uses: actions/checkout@v3 # checkout the repository content | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # install the python version needed | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: execute py script # run main.py | |
run: python src/generate_badge.py ${{ secrets.GH_BADGE_TOKEN }} | |
- name: remove .gitignore | |
# make sure we don't have .gitignore interfere with committing badge.html in next step | |
run: rm .gitignore | |
- name: commit badge.html | |
# default url/location is https://[USERNAME].github.io/github-badge-2/src/badge.html | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Automated commit - update badge.html | |
commit_author: github-actions[bot] <> | |
file_pattern: 'src/badge.html' | |
branch: gh-pages | |
create_branch: true | |
skip_dirty_check: true | |
push_options: '--force' | |