Created
August 13, 2025 20:02
-
-
Save kleinlennart/817002cbe3a0195b0adfa23b33a3a849 to your computer and use it in GitHub Desktop.
Example of automatic GitHub Action with Python and uv
This file contains hidden or 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: Weekly Data Fetch | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # runs every Sunday at midnight UTC | |
workflow_dispatch: # allows manual trigger | |
permissions: | |
contents: write # grants permission to push changes | |
jobs: | |
update-data: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up uv (Python package manager) | |
uses: astral-sh/setup-uv@v6 | |
with: | |
enable-cache: true | |
- name: Install uv dependencies from lockfile | |
run: uv sync --frozen | |
- name: Run data fetch script | |
env: | |
API_TOKEN: ${{ secrets.API_TOKEN }} | |
run: uv run python src/github-actions/01-auto_fetch_api.py | |
- name: Run data cleaning script | |
run: uv run python src/github-actions/02-clean_data.py | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Automated data update: Refresh data files [GitHub Actions]" || exit 0 | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment