Files
backstage/.github/workflows/sync_pull-requests-scheduled.yml
T
renovate[bot] 132047b4c0 chore(deps): update step-security/harden-runner action to v2.15.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-09 20:10:06 +00:00

95 lines
2.9 KiB
YAML

name: Sync Pull Requests Scheduled
on:
schedule:
# Every 30 minutes, processing a rotating batch of PRs
- cron: '*/30 * * * *'
workflow_dispatch:
permissions: {}
jobs:
plan:
permissions:
pull-requests: read
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
matrix: ${{ steps.batch.outputs.matrix }}
count: ${{ steps.batch.outputs.count }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
with:
egress-policy: audit
- name: Determine PR batch
id: batch
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
// 48 slots per day (one per 30-minute cron window).
// Each PR is assigned a fixed slot via pr.number % 48, so
// opening/closing other PRs never shifts the assignment.
const totalSlots = 48;
const now = new Date();
const currentSlot =
now.getUTCHours() * 2 + (now.getUTCMinutes() >= 30 ? 1 : 0);
const prs = await github.paginate(github.rest.pulls.list, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
});
const batch = prs.filter(
pr => pr.number % totalSlots === currentSlot,
);
core.info(
`Slot ${currentSlot}/${totalSlots}: ` +
`${batch.length} PRs to process out of ${prs.length} open`,
);
const matrix = {
include: batch.map(pr => ({ prNumber: String(pr.number) })),
};
core.setOutput('matrix', JSON.stringify(matrix));
core.setOutput('count', String(batch.length));
sync:
needs: plan
if: needs.plan.outputs.count > 0
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
fail-fast: false
max-parallel: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
with:
egress-policy: audit
- name: Backstage PR automation
uses: backstage/actions/pr-automation@2cd6978b476cbdc39fec48346f8b6ca13199dd6a # v0.7.8
with:
app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }}
private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }}
installation-id: ${{ secrets.BACKSTAGE_GOALIE_INSTALLATION_ID }}
project-owner: backstage
project-number: '14'
pr-number: ${{ matrix.prNumber }}
action: synchronize
required-checks: |
DCO
E2E Linux 22.x
E2E Linux 24.x
Test 22.x
Test 24.x
Verify 22.x
Verify 24.x