Skip to content

Update Acknowledgements #65020

Update Acknowledgements

Update Acknowledgements #65020

# Update the Acknowledgements.md file by periodically running a python script. !@#$!@$%!#$%
name: Update Acknowledgements
# Controls when the action will run
on:
# Action is triggered manually
workflow_dispatch:
# Action runs periodically
schedule:
- cron: "*/5 * * * *" # Every 5 minutes. See crontab.guru/
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "regenerate-acknowledgements"
regenerate-acknowledgements:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: master # Checkout the branch with this name
- name: Use cache
uses: actions/cache@v4
with: # Note: Setting `enableCrossOsArchive: true` would kinda make sense because the cached data is not OS specific. But we only run on Ubuntu at the moment, so it's whatever.
path: Markdown/gumroad_sales_cache.json
key: gumroad_sales_cache-${{ github.run_id }}-${{ github.run_attempt }} # A cache is immutable. To get the cache to behave as if it's updatable, the key needs to change on every run, so that there's a new cache every run. Then `restore-keys` can be used to restore the latest cache. Source: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache)
restore-keys: |
gumroad_sales_cache-
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies. This is from the official example. Not totally sure what we're doing here.
cache-dependency-path: './Markdown/Code/python_requirements.txt'
- name: Install python dependencies
run: |
python -m pip install -r ./Markdown/Code/python_requirements.txt
- name: Run script
run: |
python ./Markdown/Code/markdown_generator.py --document acknowledgements --api_key ${{ secrets.GUMROAD_API_KEY }}
- name: Commit and push changes
run: |
if [[ -n $(git status --short) ]]; then
# We do if statement here, otherwise the GitHub Actions exits with an error if there are no changes which we don't want since it's normal to have no changes. Src for the if condition: https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "GitHub Actions Workflow automatically regenerated Acknowledgements.md"
git push
else
echo 'No changes. Not commiting and pushing'
fi