Debian Codegraph @

.github/workflows/autodeps.yml

raw
1 name: Autodeps
2
3 on:
4 workflow_dispatch:
5 schedule:
6 - cron: '0 0 1 * *'
7
8 jobs:
9 Autodeps:
10 if: github.repository_owner == 'python-trio'
11 name: Autodeps
12 timeout-minutes: 10
13 runs-on: 'ubuntu-latest'
14 # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
15 permissions:
16 pull-requests: write
17 issues: write
18 repository-projects: write
19 contents: write
20
21 steps:
22 - name: Checkout
23 uses: actions/checkout@v7
24 with:
25 persist-credentials: true # credentials are needed to push commits
26 - name: Setup python
27 uses: actions/setup-python@v6
28 with:
29 python-version: "3.10"
30
31 - name: Bump dependencies
32 run: |
33 python -m pip install -U pip pre-commit
34 python -m pip install -r test-requirements.txt
35 uv pip compile --universal --python-version=3.10 --upgrade test-requirements.in -o test-requirements.txt
36 uv pip compile --universal --python-version=3.11 --upgrade docs-requirements.in -o docs-requirements.txt
37 pre-commit autoupdate --jobs 0
38
39 - name: Install new requirements
40 run: python -m pip install -r test-requirements.txt
41
42 - name: Pre-commit fixes
43 run: pre-commit run -a || true
44
45 - name: Commit changes and create automerge PR
46 env:
47 GH_TOKEN: ${{ github.token }}
48 run: |
49 # setup git repo
50 git switch --force-create autodeps/bump_from_${GITHUB_SHA:0:6}
51 git config user.name 'github-actions[bot]'
52 git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
53
54 if ! git commit -am "Dependency updates"; then
55 echo "No changes to commit!"
56 exit 0
57 fi
58
59 git push --force --set-upstream origin autodeps/bump_from_${GITHUB_SHA:0:6}
60
61 # git push returns before github is ready for a pr, so we poll until success
62 for BACKOFF in 1 2 4 8 0; do
63 sleep $BACKOFF
64 if gh pr create \
65 --label dependencies --body "" \
66 --title "Bump dependencies from commit ${GITHUB_SHA:0:6}" \
67 ; then
68 break
69 fi
70 done
71
72 if [ $BACKOFF -eq 0 ]; then
73 echo "Could not create the PR"
74 exit 1
75 fi
76
77 # gh pr create returns before the pr is ready, so we again poll until success
78 # https://github.com/cli/cli/issues/2619#issuecomment-1240543096
79 for BACKOFF in 1 2 4 8 0; do
80 sleep $BACKOFF
81 if gh pr merge --auto --squash; then
82 break
83 fi
84 done
85
86 if [ $BACKOFF -eq 0 ]; then
87 echo "Could not set automerge"
88 exit 1
89 fi