mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 11:25:06 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Chore, CI hardening ## Additional context Hardens all GitHub actions to recommendations of [zizmor](https://docs.zizmor.sh/audits/) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Disabled persistence of checkout credentials across many CI workflows to reduce credential exposure. * Upgraded GitHub App token tooling and tightened generated token permissions for automation. * Added cooldown/rate-limiting to dependency update automation to reduce update churn. * Adjusted workflow-level permissions, required secret inputs for workflow callers, and refactored some job step logic. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46454?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ali Waseem <waseema393@gmail.com>
67 lines
2.5 KiB
YAML
67 lines
2.5 KiB
YAML
name: Cleanup Braintrust preview scorers
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
cleanup-scorers:
|
|
name: Delete preview scorers
|
|
if: contains(github.event.pull_request.labels.*.name, 'preview-scorers') && github.event.pull_request.head.repo.full_name == github.repository
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
- name: Delete preview scorers from staging
|
|
env:
|
|
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
|
|
BRAINTRUST_STAGING_PROJECT_ID: ${{ secrets.BRAINTRUST_STAGING_PROJECT_ID }}
|
|
run: |
|
|
BRANCH_SLUG=$(echo "${GITHUB_HEAD_REF}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g')
|
|
readarray -t SLUGS < <(jq -r '.[].slug' apps/studio/evals/scorer-online-manifest.json)
|
|
|
|
for slug in "${SLUGS[@]}"; do
|
|
prefixed="${BRANCH_SLUG}-${slug}"
|
|
id=$(curl -s "https://api.braintrust.dev/v1/function?project_id=${BRAINTRUST_STAGING_PROJECT_ID}&slug=${prefixed}" \
|
|
-H "Authorization: Bearer ${BRAINTRUST_API_KEY}" | jq -r '.objects[0].id // empty')
|
|
if [ -n "$id" ]; then
|
|
curl -s -X DELETE "https://api.braintrust.dev/v1/function/${id}" \
|
|
-H "Authorization: Bearer ${BRAINTRUST_API_KEY}"
|
|
echo "Deleted ${prefixed}"
|
|
else
|
|
echo "Not found: ${prefixed} (already deleted or never deployed)"
|
|
fi
|
|
done
|
|
|
|
- name: Post cleanup comment
|
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
|
with:
|
|
script: |
|
|
const prNumber = context.payload.pull_request.number
|
|
const marker = '<!-- preview-scorers-bot -->'
|
|
|
|
const { data: comments } = await github.rest.issues.listComments({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: prNumber,
|
|
})
|
|
|
|
const existing = comments.find(c => c.body?.includes(marker))
|
|
if (!existing) return
|
|
|
|
await github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: existing.id,
|
|
body: `${marker}\n### Braintrust Preview Scorers\n\nPreview scorers have been cleaned up.`,
|
|
})
|