|
9 | 9 | branches: |
10 | 10 | - master |
11 | 11 |
|
12 | | - workflow_run: # chain from the uv-lock workflow |
13 | | - workflows: ["uv.lock on Dependabot PRs"] |
14 | | - types: [completed] |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
15 | 15 |
|
16 | 16 | jobs: |
17 | 17 | build: |
18 | | - # Only run if not a Dependabot PR, or once uv-lock has completed successfully |
19 | | - if: | |
20 | | - github.event_name == 'workflow_run' || |
21 | | - github.actor != 'dependabot[bot]' |
22 | 18 | runs-on: ubuntu-latest |
23 | 19 | strategy: |
24 | 20 | matrix: |
25 | 21 | python: ["3.10", "3.11", "3.12", "3.13"] |
26 | 22 |
|
27 | 23 | steps: |
| 24 | + - uses: actions/create-github-app-token@v1 |
| 25 | + id: app |
| 26 | + with: |
| 27 | + app-id: ${{ secrets.APP_ID }} |
| 28 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
28 | 29 | - uses: actions/checkout@v5 |
| 30 | + with: |
| 31 | + ref: ${{ github.event.pull_request.head.ref }} |
| 32 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 33 | + token: ${{ steps.app.outputs.token }} |
29 | 34 | - name: Install uv and set the Python version |
30 | 35 | uses: astral-sh/setup-uv@v6 |
31 | 36 | with: |
32 | 37 | python-version: ${{ matrix.python }} |
| 38 | + # refresh lock only for Dependabot PRs |
| 39 | + - name: Refresh uv.lock (Dependabot only) |
| 40 | + if: | |
| 41 | + github.event_name == 'pull_request' && |
| 42 | + github.actor == 'dependabot[bot]' |
| 43 | + run: | |
| 44 | + uv lock |
| 45 | + if ! git diff --quiet -- uv.lock; then |
| 46 | + git config user.name "uv-lock-bot[bot]" |
| 47 | + git config user.email "uv-lock-bot[bot]@users.noreply.github.com" |
| 48 | + git add uv.lock |
| 49 | + git commit -m "chore: refresh uv.lock" |
| 50 | + git push || echo "push skipped (no perms)" |
| 51 | + fi |
33 | 52 | - name: Install dependencies |
34 | 53 | run: | |
35 | 54 | uv sync --locked --only-dev |
|
0 commit comments