-
Notifications
You must be signed in to change notification settings - Fork 9
118 lines (114 loc) · 4.12 KB
/
auto_update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
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@v3
- 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@v4
with:
python-version-file: .github/settings/auto_update.python_version
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
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: 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@v5
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