|
| 1 | +name: Component PR Welcome |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, reopened, synchronize] |
| 6 | + paths: |
| 7 | + - 'cli-tool/components/**' |
| 8 | + |
| 9 | +permissions: |
| 10 | + pull-requests: write |
| 11 | + issues: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + welcome: |
| 15 | + name: Welcome & Label |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Add review-pending label and welcome comment |
| 19 | + uses: actions/github-script@v8 |
| 20 | + with: |
| 21 | + script: | |
| 22 | + const { owner, repo } = context.repo; |
| 23 | + const prNumber = context.issue.number; |
| 24 | + const author = context.payload.pull_request.user.login; |
| 25 | +
|
| 26 | + const labelName = 'review-pending'; |
| 27 | + const labelColor = 'fbca04'; |
| 28 | + const labelDescription = 'Component PR awaiting maintainer review'; |
| 29 | + const marker = '<!-- component-pr-welcome:v1 -->'; |
| 30 | +
|
| 31 | + try { |
| 32 | + await github.rest.issues.getLabel({ owner, repo, name: labelName }); |
| 33 | + } catch (err) { |
| 34 | + if (err.status === 404) { |
| 35 | + await github.rest.issues.createLabel({ |
| 36 | + owner, |
| 37 | + repo, |
| 38 | + name: labelName, |
| 39 | + color: labelColor, |
| 40 | + description: labelDescription, |
| 41 | + }); |
| 42 | + } else { |
| 43 | + throw err; |
| 44 | + } |
| 45 | + } |
| 46 | +
|
| 47 | + await github.rest.issues.addLabels({ |
| 48 | + owner, |
| 49 | + repo, |
| 50 | + issue_number: prNumber, |
| 51 | + labels: [labelName], |
| 52 | + }); |
| 53 | +
|
| 54 | + const existing = await github.paginate( |
| 55 | + github.rest.issues.listComments, |
| 56 | + { owner, repo, issue_number: prNumber, per_page: 100 } |
| 57 | + ); |
| 58 | + if (existing.some(c => c.body && c.body.includes(marker))) { |
| 59 | + core.info('Welcome comment already posted — skipping comment, label ensured.'); |
| 60 | + return; |
| 61 | + } |
| 62 | +
|
| 63 | + const body = [ |
| 64 | + marker, |
| 65 | + `## 👋 Thanks for contributing, @${author}!`, |
| 66 | + ``, |
| 67 | + `This PR touches \`cli-tool/components/**\` and has been marked **\`review-pending\`**.`, |
| 68 | + ``, |
| 69 | + `### What happens next`, |
| 70 | + `1. 🤖 **Automated security audit** runs and posts results on this PR.`, |
| 71 | + `2. 👀 **Maintainer review** — a human reviewer validates the component with the \`component-reviewer\` agent (format, naming, security, clarity).`, |
| 72 | + `3. ✅ **Merge** — once approved, your PR is merged to \`main\`.`, |
| 73 | + `4. 📦 **Catalog regeneration** — the component catalog is rebuilt automatically.`, |
| 74 | + `5. 🚀 **Live on [aitmpl.com](https://www.aitmpl.com)** — your component appears on the website after deploy.`, |
| 75 | + ``, |
| 76 | + `### While you wait`, |
| 77 | + `- Check the **Security Audit** comment below for any issues to fix.`, |
| 78 | + `- Make sure your component follows the [contribution guide](https://github.com/${owner}/${repo}/blob/main/CLAUDE.md#component-system).`, |
| 79 | + ``, |
| 80 | + `_This is an automated message. No action is required from you right now — a maintainer will review soon._`, |
| 81 | + ].join('\n'); |
| 82 | +
|
| 83 | + await github.rest.issues.createComment({ |
| 84 | + owner, |
| 85 | + repo, |
| 86 | + issue_number: prNumber, |
| 87 | + body, |
| 88 | + }); |
0 commit comments