Update Data #107
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 Data | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
# Run 4 times a day (every 6 hours) | |
# At minute 17 past hour 0, 6, 12, and 18 | |
# https://crontab.guru/#17_6,18_*_*_* | |
- cron: '17 0,6,12,18 * * *' | |
jobs: | |
update: | |
permissions: | |
contents: write | |
name: Update data | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get current week | |
uses: josStorer/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-ww | |
- name: Cache File | |
uses: actions/cache@v4 | |
with: | |
# Use current week number as cache | |
path: .cache.pkl | |
key: "cache-${{ steps.current-time.outputs.formattedTime }}" | |
- name: Cache File | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/.cache/event-fetcher-cache.sqlite | |
key: "cache-requests-${{ steps.current-time.outputs.formattedTime }}" | |
- uses: actions/checkout@v4 | |
name: Clone self repository | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Setup | |
run: | | |
git config --global init.defaultBranch main | |
git config --global extensions.partialClone true | |
pip install -r requirements.txt | |
- name: Fetch updates | |
run: rm out/* && make all && make db | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
id: upload | |
with: | |
name: events.db | |
path: events.db | |
if-no-files-found: error | |
retention-days: 90 | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
name: Commit | |
with: | |
commit_message: | | |
Automatic Updates 🤖 | |
Database URL: ${{ steps.upload.outputs.artifact-url }} | |
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/workflow | |
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>' | |
add_options: "--ignore-removal --update" | |
file_pattern: "out/*" | |
status_options: '--untracked-files=no' | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |