mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-21 12:16:15 +08:00
## Summary Pin the shared actions and reusable workflow to commit `67dc9ee1ddc113eccd8116e7b949fb6cdcd89889` from [release 2026.11.16.0](https://github.com/astral-sh/github-actions/releases/tag/2026.11.16.0). Add the release version beside each YAML pin. The token-service policy matches the new security-review workflow SHA. ## Notes to reviewers Parsed the changed YAML and JSON and verified that each referenced action or reusable workflow exists at the pinned commit. The repository’s changed-file prek hooks passed for all 15 files.
108 lines
4.2 KiB
YAML
108 lines
4.2 KiB
YAML
name: Sync ruff-security
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: sync-ruff-security-main
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
sync:
|
|
name: Sync ruff-security
|
|
if: github.repository == 'astral-sh/ruff' && github.ref == 'refs/heads/main'
|
|
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
|
|
environment:
|
|
name: automations
|
|
deployment: false
|
|
permissions:
|
|
id-token: write # for the credential broker
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
env:
|
|
SOURCE_SHA: ${{ github.sha }}
|
|
steps:
|
|
- name: Prepare public history
|
|
env:
|
|
SYNC_REPOSITORY: ${{ runner.temp }}/ruff-security-sync.git
|
|
run: |
|
|
if [[ ! "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::Expected a public commit SHA."
|
|
exit 1
|
|
fi
|
|
|
|
# Keep the object database limited to public main. No checkout is needed.
|
|
git clone --quiet --bare --single-branch --branch main --no-tags --no-recurse-submodules \
|
|
https://github.com/astral-sh/ruff.git "$SYNC_REPOSITORY"
|
|
if [[ "$(git -C "$SYNC_REPOSITORY" cat-file -t "$SOURCE_SHA" 2>/dev/null)" != commit ]] ||
|
|
! git -C "$SYNC_REPOSITORY" merge-base --is-ancestor "$SOURCE_SHA" refs/heads/main; then
|
|
echo "::error::The requested commit is not on public main."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Get ruff-security token
|
|
id: token
|
|
uses: astral-sh/github-actions/simple-token-service@67dc9ee1ddc113eccd8116e7b949fb6cdcd89889 # 2026.11.16.0
|
|
with:
|
|
exchange-url: ${{ secrets.STS_API_URL }}/exchange
|
|
audience: ${{ secrets.STS_API_URL }}
|
|
repository: astral-sh/ruff-security
|
|
# Workflow permission is required to sync changes to `.github/workflows`.
|
|
permissions: |
|
|
contents: write
|
|
workflows: write
|
|
|
|
- name: Sync main
|
|
env:
|
|
GH_TOKEN: ${{ steps.token.outputs.token }}
|
|
SYNC_REPOSITORY: ${{ runner.temp }}/ruff-security-sync.git
|
|
run: |
|
|
destination_url=https://github.com/astral-sh/ruff-security.git
|
|
destination_git() {
|
|
git -C "$SYNC_REPOSITORY" \
|
|
-c credential.helper= \
|
|
-c 'credential.helper=!gh auth git-credential' "$@"
|
|
}
|
|
|
|
# Read only the private main ref, never its objects or other branches.
|
|
# Suppress remote diagnostics so private refs cannot enter public logs.
|
|
if ! destination_main=$(destination_git ls-remote --exit-code --refs \
|
|
"$destination_url" refs/heads/main 2>/dev/null); then
|
|
echo "::error::Could not read ruff-security main."
|
|
exit 1
|
|
fi
|
|
destination_sha="${destination_main%%$'\t'*}"
|
|
if [[ ! "$destination_sha" =~ ^[0-9a-f]{40}$ ||
|
|
"$destination_main" != "$destination_sha"$'\t'refs/heads/main ]]; then
|
|
echo "::error::Unexpected ruff-security main ref."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$(git -C "$SYNC_REPOSITORY" cat-file -t "$destination_sha" 2>/dev/null)" != commit ]] ||
|
|
! git -C "$SYNC_REPOSITORY" merge-base --is-ancestor \
|
|
"$destination_sha" refs/heads/main 2>/dev/null; then
|
|
echo "::error::ruff-security main is not on public main; refusing to sync."
|
|
exit 1
|
|
fi
|
|
if git -C "$SYNC_REPOSITORY" merge-base --is-ancestor "$SOURCE_SHA" "$destination_sha"; then
|
|
echo "ruff-security main already contains this public commit."
|
|
exit 0
|
|
fi
|
|
if ! git -C "$SYNC_REPOSITORY" merge-base --is-ancestor "$destination_sha" "$SOURCE_SHA"; then
|
|
echo "::error::ruff-security main has diverged from this public commit; refusing to sync."
|
|
exit 1
|
|
fi
|
|
|
|
# The explicit refspec and ordinary push cannot rewrite private main.
|
|
if ! destination_git push --quiet --no-force --no-follow-tags \
|
|
"$destination_url" "$SOURCE_SHA:refs/heads/main" > /dev/null 2>&1; then
|
|
echo "::error::Could not fast-forward ruff-security main."
|
|
exit 1
|
|
fi
|
|
echo "Synced ruff-security main to the public commit."
|