Skip to content

Perform automatic updates #265

Perform automatic updates

Perform automatic updates #265

Workflow file for this run

---
name: Perform automatic updates
on:
schedule:
- cron: 0 18 * * MON
- cron: 0 18 * * WED
- cron: 0 18 * * FRI
workflow_dispatch:
permissions:
contents: write
checks: write
statuses: write
pull-requests: write
jobs:
auto_update:
name: Run PDM Update
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set PDM version
run: |
echo "pdm_version=$(./.github/workflow_scripts/get-pdm-version-from-lock.awk pdm.lock)" >> $GITHUB_ENV
- name: Setup python
uses: actions/setup-python@v5
with:
python-version-file: .github/settings/auto_update.python_version
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
architecture: x64
version: ${{ env.pdm_version }}
prerelease: true
enable-pep582: true
allow-python-prereleases: false
- name: Disable update check
shell: bash
run: pdm config check_update false
- name: Use venv as backend
shell: bash
run: pdm config venv.backend venv
- name: Install all dependencies from lock file
shell: bash
run: pdm install -G:all
- name: Perform dry-run update
shell: bash
id: package_update
run: |
pdm update --dry-run --update-all 2>/dev/null 1>output.txt
_pdm_output=$(cat output.txt)
_next_output=$(echo ${_pdm_output})
echo "PDM_UPDATE_OUTPUT<<EOF" >> $GITHUB_ENV
echo "${_next_output}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo $_next_output
_next_output=$(tail -n+2 output.txt)
echo "PDM_PACKAGES_TO_UPDATE<<EOF" >> $GITHUB_ENV
echo "${_next_output}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo $_next_output
_next_output=$(tail -n+3 output.txt)
echo "PDM_UPDATED_PACKAGES_NAMES<<EOF" >> $GITHUB_ENV
echo "${_next_output}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo $_next_output
_next_output=$(tail -n+3 output.txt | wc -l)
echo "PDM_NUMBER_OF_NEW_PACKAGES=${_next_output}" >> $GITHUB_ENV
rm output.txt
- name: "Update dependencies"
run: pdm update --no-sync --update-all
shell: bash
- name: Detect changes
id: detect-changes
shell: bash
run: |
_no_changed_files=$(git status --porcelain | wc -l)
if [ $_no_changed_files -ne 0 ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Install plugin itself
shell: bash
run: pdm install --plugins
if: ${{ steps.detect-changes.outputs.changed == 'true' }}
- name: "Increase dev version"
shell: bash
run: pdm bump dev
if: ${{ steps.detect-changes.outputs.changed == 'true' }}
- name: Setup Commit message and PR Title
id: text_formatting
shell: bash
run: |
echo "GIT_PDM_TITLE=chore: Updated ${{ env.PDM_NUMBER_OF_NEW_PACKAGES }} dependencies in pdm.lock" >> $GITHUB_ENV
if: ${{ steps.detect-changes.outputs.changed == 'true' }}
- name: Commit and create Pull request
id: create-pr
uses: peter-evans/create-pull-request@v6
if: ${{ steps.detect-changes.outputs.changed == 'true' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: |
pyproject.toml
pdm.lock
commit-message: |
${{ env.GIT_PDM_TITLE }}
${{ env.PDM_UPDATED_PACKAGES_NAMES }}
committer: ${{ github.repository_owner }} (Github Workflow - Auto update) <${{ github.repository_owner }}@users.noreply.github.com>
author: ${{ github.repository_owner }} (Github Workflow - Auto update) <${{ github.repository_owner }}@users.noreply.github.com>
signoff: false
branch: auto-update/dependencies
branch-suffix: timestamp
delete-branch: true
title: ${{ env.GIT_PDM_TITLE }}
body: ${{ env.PDM_PACKAGES_TO_UPDATE }}
assignees: ${{ github.repository_owner }}
draft: true