|
| 1 | +name: Notify Slack for wizard issues |
| 2 | +on: |
| 3 | + issues: |
| 4 | + types: [opened] |
| 5 | + |
| 6 | +jobs: |
| 7 | + notify: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Check issue and build payload |
| 11 | + id: check |
| 12 | + uses: actions/github-script@v7 |
| 13 | + with: |
| 14 | + script: | |
| 15 | + const issue = context.payload.issue; |
| 16 | +
|
| 17 | + // Check if the issue belongs to integration autonomy |
| 18 | + const EXCLUDED_PROJECTS = ['Integration autonomy']; |
| 19 | +
|
| 20 | + const { node } = await github.graphql(` |
| 21 | + query($issueId: ID!) { |
| 22 | + node(id: "${ issue.node_id }") { |
| 23 | + ... on Issue { |
| 24 | + projectItems(first: 10) { |
| 25 | + nodes { |
| 26 | + project { title } |
| 27 | + } |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + `, { issueId: issue.node_id }); |
| 33 | +
|
| 34 | + const projects = (node?.projectItems?.nodes || []).map(n => n.project.title); |
| 35 | + const isExcluded = projects.some(p => EXCLUDED_PROJECTS.includes(p)); |
| 36 | +
|
| 37 | + if (isExcluded) { |
| 38 | + core.info(`Skipping: issue belongs to excluded project (${projects.join(', ')})`); |
| 39 | + core.setOutput('notify', 'false'); |
| 40 | + return; |
| 41 | + } |
| 42 | +
|
| 43 | + const labels = (issue.labels || []).map(l => l.name).join(', '); |
| 44 | + const payload = { |
| 45 | + text: `New wizard issue: <${issue.html_url}|${issue.title}>\nBy: ${issue.user.login}\nLabels: ${labels || 'none'}` |
| 46 | + }; |
| 47 | + core.setOutput('notify', 'true'); |
| 48 | + core.setOutput('payload', JSON.stringify(payload)); |
| 49 | +
|
| 50 | + - name: Notify Slack |
| 51 | + if: steps.check.outputs.notify == 'true' |
| 52 | + uses: slackapi/slack-github-action@v2.0.0 |
| 53 | + with: |
| 54 | + webhook: ${{ secrets.SLACK_WEBHOOK }} |
| 55 | + webhook-type: incoming-webhook |
| 56 | + payload: ${{ steps.check.outputs.payload }} |
0 commit comments