mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 22:48:57 +02:00
Bumps the github-actions group with 10 updates in the / directory: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `4` | `7` | | [docker/login-action](https://github.com/docker/login-action) | `3` | `4` | | [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) | `3` | `4` | | [docker/build-push-action](https://github.com/docker/build-push-action) | `6` | `7` | | [actions/dependency-review-action](https://github.com/actions/dependency-review-action) | `4.9.0` | `5.0.0` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4` | `7` | | [actions/download-artifact](https://github.com/actions/download-artifact) | `4` | `8` | | [oven-sh/setup-bun](https://github.com/oven-sh/setup-bun) | `1` | `2` | | [actions/cache](https://github.com/actions/cache) | `4` | `6` | | [google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml](https://github.com/google/osv-scanner-action) | `3adb4b14a2b0623876d18d863a498b785fb3752d` | `f4cfcc01edc9c8b756a9b873b7a623ca674da51e` | Updates `actions/checkout` from 4 to 7 - [Release notes](https://github.com/actions/checkout/releases) - [Commits](https://github.com/actions/checkout/compare/v4...v7) Updates `docker/login-action` from 3 to 4 - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v3...v4) Updates `docker/setup-buildx-action` from 3 to 4 - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v3...v4) Updates `docker/build-push-action` from 6 to 7 - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6...v7) Updates `actions/dependency-review-action` from 4.9.0 to 5.0.0 - [Release notes](https://github.com/actions/dependency-review-action/releases) - [Commits](https://github.com/actions/dependency-review-action/compare/2031cfc080254a8a887f58cffee85186f0e49e48...a1d282b36b6f3519aa1f3fc636f609c47dddb294) Updates `actions/upload-artifact` from 4 to 7 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v7) Updates `actions/download-artifact` from 4 to 8 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4...v8) Updates `oven-sh/setup-bun` from 1 to 2 - [Release notes](https://github.com/oven-sh/setup-bun/releases) - [Commits](https://github.com/oven-sh/setup-bun/compare/v1...v2) Updates `actions/cache` from 4 to 6 - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4...v6) Updates `google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml` from 3adb4b14a2b0623876d18d863a498b785fb3752d to f4cfcc01edc9c8b756a9b873b7a623ca674da51e - [Release notes](https://github.com/google/osv-scanner-action/releases) - [Commits](https://github.com/google/osv-scanner-action/compare/3adb4b14a2b0623876d18d863a498b785fb3752d...f4cfcc01edc9c8b756a9b873b7a623ca674da51e)
99 lines
4.2 KiB
YAML
99 lines
4.2 KiB
YAML
name: PR Title Sync
|
|
|
|
# WHY pull_request_target (not pull_request): the default GITHUB_TOKEN is
|
|
# READ-ONLY on fork PRs under `pull_request`, so the title-sync backstop could
|
|
# never `gh pr edit` a fork/agent PR. `pull_request_target` runs in the base-repo
|
|
# context with a write token, which fixes fork coverage.
|
|
#
|
|
# WHY this is SAFE (pull_request_target is the most dangerous trigger):
|
|
# - We check out the BASE repo (no `ref:`), so the only code we execute is
|
|
# trusted base-repo infra (bin/gstack-pr-title-rewrite.sh). We NEVER check
|
|
# out or run PR-head/fork code.
|
|
# - Every attacker-controlled PR field (title, head repo, head sha) arrives via
|
|
# `env:` and is referenced as a shell-quoted "$VAR". We NEVER inline a
|
|
# `${{ github.event.pull_request.* }}` expression inside the run: script
|
|
# (that would execute a crafted title as shell).
|
|
# - The PR-head VERSION is read as DATA via the API (raw media type), from the
|
|
# head repo at the head sha — never by checking out the head.
|
|
# test/pr-title-sync-workflow-safety.test.ts is the static tripwire for all of
|
|
# the above and fails CI if any of it regresses.
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, synchronize, edited]
|
|
paths:
|
|
- 'VERSION'
|
|
|
|
concurrency:
|
|
group: pr-title-sync-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
sync:
|
|
name: Sync PR title to VERSION
|
|
runs-on: ubicloud-standard-2
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
if: github.actor != 'github-actions[bot]'
|
|
steps:
|
|
# Base repo only — trusted infra (the rewrite helper). No PR-head checkout.
|
|
- name: Checkout base repo (trusted)
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Rewrite PR title to match VERSION
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUM: ${{ github.event.pull_request.number }}
|
|
# Attacker-controlled on fork PRs — env-only, never inlined into run:.
|
|
OLD_TITLE: ${{ github.event.pull_request.title }}
|
|
BASE_REPO: ${{ github.repository }}
|
|
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
chmod +x ./bin/gstack-pr-title-rewrite.sh
|
|
|
|
if [ "$HEAD_REPO" = "$BASE_REPO" ]; then IS_FORK=0; else IS_FORK=1; fi
|
|
|
|
# Read the PR-head VERSION as data (raw bytes), from the head repo at
|
|
# the head sha. Guard the assignment itself: under `set -e` a bare
|
|
# `VERSION=$(...)` would abort the step before any later [ -z ] check.
|
|
if ! VERSION=$(gh api -H "Accept: application/vnd.github.raw" \
|
|
"repos/$HEAD_REPO/contents/VERSION?ref=$HEAD_SHA" 2>/dev/null | tr -d '[:space:]'); then
|
|
VERSION=""
|
|
fi
|
|
|
|
if [ -z "$VERSION" ]; then
|
|
# Same-repo read failure should never happen — fail loudly so we
|
|
# notice. A fork miss (public-contents quirk, private fork) is a
|
|
# convenience gap, not a gate — warn and skip so the check stays green.
|
|
if [ "$IS_FORK" = "0" ]; then
|
|
echo "::error::Could not read VERSION from same-repo PR head ($HEAD_SHA)."
|
|
exit 1
|
|
fi
|
|
echo "::warning::Could not read VERSION from fork $HEAD_REPO ($HEAD_SHA); skipping title sync."
|
|
exit 0
|
|
fi
|
|
|
|
# The helper rejects a malformed VERSION (exit 2). Same policy: loud for
|
|
# same-repo, soft for forks. Never echo the raw (attacker-controlled)
|
|
# title — Actions still parses ::workflow-command:: from stdout.
|
|
if ! NEW_TITLE=$(./bin/gstack-pr-title-rewrite.sh "$VERSION" "$OLD_TITLE"); then
|
|
if [ "$IS_FORK" = "0" ]; then
|
|
echo "::error::Could not compute title for VERSION '$VERSION' on PR #$PR_NUM."
|
|
exit 1
|
|
fi
|
|
echo "::warning::Could not compute title for fork PR #$PR_NUM; skipping."
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$NEW_TITLE" = "$OLD_TITLE" ]; then
|
|
echo "PR #$PR_NUM title already correct; no change."
|
|
exit 0
|
|
fi
|
|
gh pr edit "$PR_NUM" --title "$NEW_TITLE"
|
|
echo "PR #$PR_NUM title synced to VERSION."
|