chore(deps): Bump actions/github-script from 7 to 9 #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Review Automation | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| tier-classification: | |
| name: Classify PR Tier | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tier: ${{ steps.classify.outputs.tier }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v41 | |
| with: | |
| files_yaml: | | |
| ship: | |
| - 'docs/**' | |
| - '*.md' | |
| - 'experiments/**' | |
| - '.vscode/**' | |
| ask: | |
| - 'src/**' | |
| - 'lib/**' | |
| - 'core/**' | |
| - '.github/workflows/**' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'tsconfig.json' | |
| - '.env*' | |
| - 'security/**' | |
| - 'auth/**' | |
| - name: Classify tier | |
| id: classify | |
| run: | | |
| if [[ "${{ steps.changed-files.outputs.ship_any_changed }}" == "true" ]]; then | |
| # Check if ONLY ship files changed | |
| if [[ "${{ steps.changed-files.outputs.ask_any_changed }}" == "false" ]]; then | |
| echo "tier=SHIP" >> $GITHUB_OUTPUT | |
| echo "PR classified as SHIP tier (documentation/experiments only)" | |
| else | |
| # Mixed changes, default to ASK for safety | |
| echo "tier=ASK" >> $GITHUB_OUTPUT | |
| echo "PR classified as ASK tier (mixed critical and non-critical changes)" | |
| fi | |
| elif [[ "${{ steps.changed-files.outputs.ask_any_changed }}" == "true" ]]; then | |
| echo "tier=ASK" >> $GITHUB_OUTPUT | |
| echo "PR classified as ASK tier (critical files changed)" | |
| else | |
| echo "tier=SHOW" >> $GITHUB_OUTPUT | |
| echo "PR classified as SHOW tier (standard code changes)" | |
| fi | |
| automated-checks: | |
| name: Run Automated Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install markdownlint | |
| run: npm install -g markdownlint-cli | |
| - name: Lint markdown files | |
| run: | | |
| if ls *.md 1> /dev/null 2>&1 || ls docs/**/*.md 1> /dev/null 2>&1; then | |
| markdownlint '**/*.md' --ignore node_modules --ignore .github || true | |
| else | |
| echo "No markdown files to lint" | |
| fi | |
| - name: Check file formatting | |
| run: | | |
| # Check for trailing whitespace | |
| ! grep -r '[[:blank:]]$' --include='*.md' --include='*.yml' --include='*.yaml' . || { | |
| echo "Warning: Trailing whitespace found in files" | |
| exit 0 | |
| } | |
| label-pr: | |
| name: Label PR with Tier | |
| runs-on: ubuntu-latest | |
| needs: tier-classification | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Remove existing tier labels | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const tierLabels = ['tier:SHIP', 'tier:SHOW', 'tier:ASK']; | |
| const labels = await github.rest.issues.listLabelsOnIssue({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number | |
| }); | |
| for (const label of labels.data) { | |
| if (tierLabels.includes(label.name)) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: label.name | |
| }); | |
| } | |
| } | |
| - name: Add tier label | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const tier = '${{ needs.tier-classification.outputs.tier }}'; | |
| const labelName = `tier:${tier}`; | |
| // Ensure label exists | |
| try { | |
| await github.rest.issues.getLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: labelName | |
| }); | |
| } catch (error) { | |
| // Create label if it doesn't exist | |
| const colors = { | |
| 'SHIP': '0e8a16', // green | |
| 'SHOW': 'fbca04', // yellow | |
| 'ASK': 'd93f0b' // red | |
| }; | |
| await github.rest.issues.createLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: labelName, | |
| color: colors[tier], | |
| description: `${tier} tier PR` | |
| }); | |
| } | |
| // Add label to PR | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: [labelName] | |
| }); | |
| - name: Add tier comment | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const tier = '${{ needs.tier-classification.outputs.tier }}'; | |
| const descriptions = { | |
| 'SHIP': '🚢 **SHIP tier** - Documentation/experiments only. Auto-merge eligible after checks pass.', | |
| 'SHOW': '👀 **SHOW tier** - Standard code changes. Asynchronous review within 24 hours.', | |
| 'ASK': '🔍 **ASK tier** - Critical changes requiring synchronous review. First response within 4 hours.' | |
| }; | |
| const slas = { | |
| 'SHIP': 'Immediate (auto-merge)', | |
| 'SHOW': '24 hours', | |
| 'ASK': '4 hours first response, same-day completion' | |
| }; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `${descriptions[tier]}\n\n**SLA Target:** ${slas[tier]}` | |
| }); |