Autoupdate dependencies #1
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: Autoupdate dependencies | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 1 * *" | |
jobs: | |
auto-update-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/python-poetry-env | |
- name: Install tabulate | |
run: python -m pip install tabulate | |
- name: Gather outdated dependencies | |
id: check_for_outdated_dependencies | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
body=$(poetry show -o -n) | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
{ | |
echo "body<<$EOF" | |
echo "$body" | |
echo "$EOF" | |
} >> "$GITHUB_OUTPUT" | |
echo "$body" | |
- name: Format PR message | |
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 }} | |
id: get_outdated_dependencies | |
shell: bash | |
run: | | |
body=$(poetry show -o -n | sed 's/(!)//' | awk 'BEGIN {print "Package","Used","Update"}; {print $1,$2,$3}' | tabulate --header --format github -) | |
body=$(cat <<EOF | |
The following packages are outdated | |
$body | |
EOF | |
) | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
{ | |
echo "body<<$EOF" | |
echo "$body" | |
echo "$EOF" | |
} >> "$GITHUB_OUTPUT" | |
echo "$body" | |
- name: Update outdated packages | |
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 }} | |
run: poetry lock | |
# behaviour if PR already exists: https://github.com/marketplace/actions/create-pull-request#action-behaviour | |
- name: Create Pull Request | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 && env.GITHUB_TOKEN != 0 }} | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
commit-message: >- | |
chore: update dependencies | |
title: "[Actions] Auto-Update dependencies" | |
body: ${{ steps.get_outdated_dependencies.outputs.body }} | |
branch: chore/update-dependencies | |
delete-branch: true |