Skip to content

perf(api): Use lightweight contexts across control permissions #288497

perf(api): Use lightweight contexts across control permissions

perf(api): Use lightweight contexts across control permissions #288497

# Dispatch a request to getsentry to run getsentry test suites

Check warning on line 1 in .github/workflows/getsentry-dispatch.yml

View workflow run for this annotation

GitHub Actions / getsentry dispatcher

Workflow execution policy warning (evaluate mode)

On December 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
name: getsentry dispatcher
on:
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
# this to run on forks. It allows forks to access secrets safely by
# only running workflows from the main branch. Prefer to use `pull_request` when possible.
#
# See https://github.com/getsentry/sentry/pull/21600 for more details
pull_request_target:
types: [labeled, opened, reopened, synchronize]
# disable all other special privileges
permissions:
# needed for `actions/checkout` to clone the code
contents: read
# needed to remove the pull-request label
pull-requests: write
jobs:
dispatch:
if: "github.event.action != 'labeled' || github.event.label.name == 'Trigger: getsentry tests'"
name: getsentry dispatch
# Job-level so unrelated `labeled` events, which skip this job, don't cancel it.
concurrency:
group: getsentry-dispatch-${{ github.event.number }}
cancel-in-progress: true
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: permissions
run: |
python3 -uS .github/workflows/scripts/getsentry-dispatch-setup \
--repo-id ${{ github.event.repository.id }} \
--pr ${{ github.event.number }} \
--event ${{ github.event.action }} \
--username "$ARG_USERNAME" \
--label-names "$ARG_LABEL_NAMES"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# these can contain special characters
ARG_USERNAME: ${{ github.event.pull_request.user.login }}
ARG_LABEL_NAMES: ${{ toJSON(github.event.pull_request.labels.*.name) }}
- name: Check for file changes
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
- name: Get changed files for selective testing
id: changed-files
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api repos/${{ github.repository }}/pulls/${{ github.event.number }}/files \
--paginate | python3 .github/workflows/scripts/parse-pr-files.py >> "$GITHUB_OUTPUT"
- name: getsentry token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: getsentry
with:
client-id: ${{ vars.SENTRY_INTERNAL_APP_ID }}
private-key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
repositories: |
sentry
getsentry
- name: Wait for PR merge commit
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
id: mergecommit
with:
github-token: ${{ steps.getsentry.outputs.token }}
script: |
const { waitForMergeCommit } = await import(`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/wait-for-merge-commit.js`);
await waitForMergeCommit({
github,
context,
core,
});
- name: Dispatch getsentry tests
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
env:
SENTRY_CHANGED_FILES: ${{ steps.changed-files.outputs.files }}
SENTRY_PREVIOUS_FILENAMES: ${{ steps.changed-files.outputs.previous-filenames }}
with:
github-token: ${{ steps.getsentry.outputs.token }}
script: |
const { dispatch } = await import(`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/getsentry-dispatch.js`);
await dispatch({
github,
context,
core,
mergeCommitSha: '${{ steps.mergecommit.outputs.mergeCommitSha }}',
fileChanges: ${{ toJson(steps.changes.outputs) }},
sentryChangedFiles: process.env.SENTRY_CHANGED_FILES,
sentryPreviousFilenames: process.env.SENTRY_PREVIOUS_FILENAMES,
});