Imagine that you have a static site and a data file has to update periodically from an API. Or, you want to fix code style issues on every commit. Or, update the contributors' list automatically whenever somebody contributes.
All these are possible with GitHub Action, and one thing is common in them. In the end, you want to persist the updates.
With the checkout action, this is extremely easy.
Once you referenced the action, you can use the familiar Git
Here's an example from an actual project using scheduled actions where a file is updated every 6 hours:
name: Update daily schedule
- cron: '0 */6 * * *'
name: Update data
+ - name: Checkout code
+ uses: actions/checkout@v2
- name: Fetch the data and save it
curl "https://tilos.hu/api/v1/episode?start=$(date --date='-12 hour' +%s)000&end=$(date --date='+12 hour' +%s)000" -o public/daily-schedule.json
+ git config user.name github-actions
+ git config user.email email@example.com
+ git add .
+ git commit -m "Update daily-schedule.json"
+ git push
The commit will appear as expected in Git history.