Skip to content

Commit 9b3a3b6

Browse files
authored
🔐 Use PR Submit for pull requests (#2071)
1 parent f299d20 commit 9b3a3b6

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

.github/pr-submit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
workflows:
2+
- .github/workflows/bump-pre-commit-hooks.yml
3+
- .github/workflows/prepare-release.yml

.github/workflows/bump-pre-commit-hooks.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ jobs:
1212
if: github.repository_owner == 'fastapi'
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 10
15+
permissions:
16+
contents: read
17+
id-token: write
1518
steps:
1619
- name: Dump GitHub context
1720
env:
1821
GITHUB_CONTEXT: ${{ toJson(github) }}
1922
run: echo "$GITHUB_CONTEXT"
2023
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2124
with:
22-
token: ${{ secrets.SQLMODEL_LATEST_CHANGES }}
23-
persist-credentials: true
25+
persist-credentials: false
2426
- name: Set up Python
2527
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
2628
with:
@@ -36,22 +38,26 @@ jobs:
3638
uv.lock
3739
- name: Bump pre-commit hooks
3840
run: uv run prek auto-update --freeze --cooldown-days 7
41+
- name: Get PR Submit token
42+
id: pr-submit
43+
uses: tiangolo/pr-submit@d802fdf59bde80bc3eb8bd3259f4cbeec63de4aa # 0.0.1
3944
- name: Create pull request
4045
env:
41-
GH_TOKEN: ${{ secrets.SQLMODEL_LATEST_CHANGES }}
46+
GH_TOKEN: ${{ steps.pr-submit.outputs.token }}
4247
BASE_BRANCH: ${{ github.event.repository.default_branch }}
4348
run: |
4449
set -euo pipefail
4550
if git diff --quiet; then
4651
echo "No pre-commit hook updates available"
4752
exit 0
4853
fi
49-
git config user.name "github-actions[bot]"
50-
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
git config user.name "pr-submit[bot]"
55+
git config user.email "pr-submit[bot]@users.noreply.github.com"
5156
branch="bump-pre-commit-hooks"
5257
git switch -C "$branch"
5358
git add .pre-commit-config.yaml
5459
git commit -m "⬆ Bump pre-commit hooks"
60+
gh auth setup-git
5561
git push --force origin "$branch"
5662
if [ -z "$(gh pr list --head "$branch" --state open --json number --jq '.[].number')" ]; then
5763
gh pr create \

.github/workflows/prepare-release.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ jobs:
2323
runs-on: ubuntu-latest
2424
timeout-minutes: 5
2525
permissions:
26-
contents: write
27-
issues: write
28-
pull-requests: write
26+
contents: read
27+
id-token: write
2928
env:
3029
PREPARE_RELEASE_VERSION_FILE: sqlmodel/__init__.py
3130
PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/release-notes.md
@@ -36,8 +35,7 @@ jobs:
3635
run: echo "$GITHUB_CONTEXT"
3736
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3837
with:
39-
token: ${{ secrets.SQLMODEL_LATEST_CHANGES }} # zizmor: ignore[secrets-outside-env]
40-
persist-credentials: true
38+
persist-credentials: false
4139
- name: Set up Python
4240
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
4341
with:
@@ -59,18 +57,22 @@ jobs:
5957
version="$(uv run python scripts/prepare_release.py current-version)"
6058
echo "$version"
6159
echo "version=$version" >> "$GITHUB_OUTPUT"
60+
- name: Get PR Submit token
61+
id: pr-submit
62+
uses: tiangolo/pr-submit@d802fdf59bde80bc3eb8bd3259f4cbeec63de4aa # 0.0.1
6263
- name: Create release pull request
6364
env:
64-
GH_TOKEN: ${{ secrets.SQLMODEL_LATEST_CHANGES }}
65+
GH_TOKEN: ${{ steps.pr-submit.outputs.token }}
6566
VERSION: ${{ steps.release-version.outputs.version }}
6667
run: |
6768
set -euo pipefail
6869
branch="release-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
69-
git config user.name "github-actions[bot]"
70-
git config user.email "github-actions[bot]@users.noreply.github.com"
70+
git config user.name "pr-submit[bot]"
71+
git config user.email "pr-submit[bot]@users.noreply.github.com"
7172
git switch -c "$branch"
7273
git add "$PREPARE_RELEASE_VERSION_FILE" "$PREPARE_RELEASE_RELEASE_NOTES_FILE"
7374
git commit -m "Release version ${VERSION}"
75+
gh auth setup-git
7476
git push --set-upstream origin "$branch"
7577
gh pr create \
7678
--base main \

0 commit comments

Comments
 (0)