Created
July 17, 2024 21:56
-
-
Save ipmb/23320949efa9c673f1cc2b135abb6811 to your computer and use it in GitHub Desktop.
uv update dependencies GH Action workflow
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: Update Python dependencies | |
on: | |
workflow_dispatch: {} | |
schedule: | |
# Run every Wednesday 6AM | |
- cron: "0 6 * * 3" | |
jobs: | |
update: | |
runs-on: ubuntu-22.04 | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12.1" | |
cache: "pip" | |
- name: Install current list of packages | |
run: | | |
pip install -U pip uv | |
uv venv | |
uv pip sync --require-hashes requirements.txt | |
- name: Update Requirements | |
run: | | |
bin/requirements.sh | |
- name: Obtain installable packages | |
id: variables | |
run: | | |
echo "would_update=$(uv pip install --dry-run -r requirements.txt | grep 'Would install')" >> $GITHUB_OUTPUT | |
export MARKER=EOFEOF | |
echo "diff<<$MARKER" >> $GITHUB_OUTPUT | |
git diff -U0 -- requirements.txt | grep '==' | grep -v '@@' | sed 's/ \\$//' | tee -a $GITHUB_OUTPUT | |
echo "$MARKER" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
add-paths: | | |
requirements.txt | |
commit-message: 'Update Python dependencies to their latest version.' | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
branch: dependency-updates | |
delete-branch: true | |
title: '📦 Update Python dependencies' | |
labels: automated, dependencies | |
body: | | |
${{ steps.variables.outputs.would_update }} | |
```diff | |
${{ steps.variables.outputs.diff }} | |
``` | |
This pull request was automatically created. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment