Compare commits

...

2 Commits

Author SHA1 Message Date
latest-changes[bot] e5cdc73405 📝 Update release notes
[skip ci]
2026-08-08 16:07:42 +00:00
Sebastián Ramírez 96c1147ee7 🔒 Replace pre-commit PAT with PR Push (#2407) 2026-08-08 18:07:39 +02:00
3 changed files with 28 additions and 11 deletions
+2
View File
@@ -0,0 +1,2 @@
workflows:
- .github/workflows/pre-commit.yml
+25 -11
View File
@@ -2,16 +2,17 @@ name: pre-commit
on: on:
pull_request: pull_request:
permissions: permissions: {}
contents: read
env: env:
# Forks and Dependabot don't have access to secrets CAN_PUSH: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
jobs: jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
timeout-minutes: 5 timeout-minutes: 5
steps: steps:
- name: Dump GitHub context - name: Dump GitHub context
@@ -20,20 +21,18 @@ jobs:
run: echo "$GITHUB_CONTEXT" run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
name: Checkout PR for own repo name: Checkout PR for own repo
if: env.HAS_SECRETS == 'true' if: env.CAN_PUSH == 'true'
with: with:
# To be able to commit it needs to fetch the head of the branch, not the # To be able to commit it needs to fetch the head of the branch, not the
# merge commit # merge commit
ref: ${{ github.head_ref }} ref: ${{ github.head_ref }}
# And it needs the full history to be able to compute diffs # And it needs the full history to be able to compute diffs
fetch-depth: 0 fetch-depth: 0
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI persist-credentials: false
token: ${{ secrets.PRE_COMMIT }} # zizmor: ignore[secrets-outside-env]
persist-credentials: true # Required for `git push` command
# pre-commit lite ci needs the default checkout configs to work # pre-commit lite ci needs the default checkout configs to work
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
name: Checkout PR for fork name: Checkout PR for fork
if: env.HAS_SECRETS == 'false' if: env.CAN_PUSH == 'false'
with: with:
# To be able to commit it needs the head branch of the PR, the remote one # To be able to commit it needs the head branch of the PR, the remote one
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
@@ -64,11 +63,26 @@ jobs:
id: precommit id: precommit
run: uv run prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure run: uv run prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
continue-on-error: true continue-on-error: true
- name: Check for changes
id: changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Get PR Push token
id: pr-push
if: env.CAN_PUSH == 'true' && steps.changes.outputs.changed == 'true'
uses: tiangolo/pr-push@ff4e51a433de4c22bbf90597e069e8247b9203d2 # 0.0.1
- name: Commit and push changes - name: Commit and push changes
if: env.HAS_SECRETS == 'true' if: env.CAN_PUSH == 'true' && steps.changes.outputs.changed == 'true'
env:
PR_PUSH_TOKEN: ${{ steps.pr-push.outputs.token }}
run: | run: |
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${PR_PUSH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git add -A git add -A
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes to commit" echo "No changes to commit"
@@ -77,7 +91,7 @@ jobs:
git push git push
fi fi
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0 - uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
if: env.HAS_SECRETS == 'false' if: env.CAN_PUSH == 'false'
with: with:
msg: 🎨 Auto format and update with pre-commit msg: 🎨 Auto format and update with pre-commit
- name: Error out on pre-commit errors - name: Error out on pre-commit errors
+1
View File
@@ -30,6 +30,7 @@
### Internal ### Internal
* 🔒 Replace pre-commit PAT with PR Push. PR [#2407](https://github.com/fastapi/full-stack-fastapi-template/pull/2407) by [@tiangolo](https://github.com/tiangolo).
* ⬆️ Bump `@hey-api/openapi-ts` from 0.73.0 to 0.97.3 and migrate to new client. PR [#2388](https://github.com/fastapi/full-stack-fastapi-template/pull/2388) by [@YuriiMotov](https://github.com/YuriiMotov). * ⬆️ Bump `@hey-api/openapi-ts` from 0.73.0 to 0.97.3 and migrate to new client. PR [#2388](https://github.com/fastapi/full-stack-fastapi-template/pull/2388) by [@YuriiMotov](https://github.com/YuriiMotov).
* 🔥 Remove the old Latest Changes workflow. PR [#2403](https://github.com/fastapi/full-stack-fastapi-template/pull/2403) by [@tiangolo](https://github.com/tiangolo). * 🔥 Remove the old Latest Changes workflow. PR [#2403](https://github.com/fastapi/full-stack-fastapi-template/pull/2403) by [@tiangolo](https://github.com/tiangolo).
* ⬆ Update psycopg[binary] requirement from <4.0.0,>=3.1.13 to >=3.3.4,<4.0.0. PR [#2399](https://github.com/fastapi/full-stack-fastapi-template/pull/2399) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ Update psycopg[binary] requirement from <4.0.0,>=3.1.13 to >=3.3.4,<4.0.0. PR [#2399](https://github.com/fastapi/full-stack-fastapi-template/pull/2399) by [@dependabot[bot]](https://github.com/apps/dependabot).