Skip to content

fix(presets): round-trip routing.md in preset save/apply #663

fix(presets): round-trip routing.md in preset save/apply

fix(presets): round-trip routing.md in preset save/apply #663

Workflow file for this run

name: Squad Impact Analysis
on:
pull_request_target:
branches: [dev]
types: [opened, synchronize, reopened]
# Security: Using pull_request_target so we get a write token for fork PRs.
# Scripts are checked out from the BASE branch (trusted), not the PR head.
# PR data is fetched read-only via gh CLI — no untrusted code is executed.
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
impact:
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout scripts (base branch only)
uses: actions/checkout@v7
with:
sparse-checkout: |
scripts/analyze-impact.mjs
scripts/impact-utils/parse-diff.mjs
scripts/impact-utils/risk-scorer.mjs
scripts/impact-utils/report-generator.mjs
sparse-checkout-cone-mode: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Run impact analysis
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: node scripts/analyze-impact.mjs ${{ github.event.pull_request.number }}
- name: Post impact report
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const marker = '<!-- squad-impact-report -->';
const report = fs.readFileSync('impact-report.md', 'utf8');
const body = `${marker}\n${report}`;
const prNumber = ${{ github.event.pull_request.number }};
// Upsert: find existing comment by marker, update or create.
// paginate() follows Link headers so we never miss an existing marker.
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
per_page: 100,
});
const existing = comments.find(c => c.body && c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
core.info('Updated existing impact report comment');
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
core.info('Created new impact report comment');
}