|
15 | 15 |
|
16 | 16 | cc_warning_message: |
17 | 17 | required: false |
18 | | - default: '⚠️ Please consider using Conventional Commits (e.g. feat:, fix:, docs:).' |
| 18 | + default: "⚠️ Please consider using Conventional Commits (e.g. feat:, fix:, docs:).\nhttps://www.conventionalcommits.org/en/v1.0.0/" |
19 | 19 | type: string |
20 | 20 |
|
21 | 21 | secrets: |
|
27 | 27 | jobs: |
28 | 28 | pr-handler: |
29 | 29 | runs-on: ubuntu-latest |
30 | | - if: github.event_name == 'pull_request' |
| 30 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
31 | 31 |
|
32 | 32 | steps: |
33 | 33 | - name: Generate DevHub Bot token |
@@ -167,63 +167,54 @@ jobs: |
167 | 167 | app-id: ${{ secrets.DEVHUB_APP_ID }} |
168 | 168 | private-key: ${{ secrets.DEVHUB_APP_PRIVATE_KEY }} |
169 | 169 |
|
170 | | - - name: Handle new issue (labels + comment) |
| 170 | + - name: Handle issue open (labels + comment) |
171 | 171 | uses: actions/github-script@v7 |
172 | 172 | with: |
173 | 173 | github-token: ${{ steps.app-token.outputs.token }} |
174 | 174 | script: | |
175 | 175 | const issue = context.payload.issue; |
176 | 176 |
|
177 | | - const text = `${issue.title}\n${issue.body || ""}`.toLowerCase(); |
178 | | -
|
179 | | - const detectedLabels = []; |
| 177 | + const text = `${issue.title}\n${issue.body ?? ""}`.toLowerCase(); |
180 | 178 |
|
181 | 179 | const rules = [ |
182 | | - { keywords: ["bug", "error", "crash", "fail"], label: "bug" }, |
183 | | - { keywords: ["feature", "request", "enhancement"], label: "enhancement" }, |
184 | | - { keywords: ["doc", "docs", "readme"], label: "documentation" }, |
185 | | - { keywords: ["question", "help"], label: "question" }, |
| 180 | + { label: "bug", keywords: ["bug", "error", "crash", "fail", "issue"] }, |
| 181 | + { label: "enhancement", keywords: ["feature", "request", "enhance"] }, |
| 182 | + { label: "documentation", keywords: ["docs", "readme", "documentation"] }, |
| 183 | + { label: "question", keywords: ["question", "help"] }, |
186 | 184 | ]; |
187 | 185 |
|
188 | | - for (const rule of rules) { |
189 | | - if ( |
190 | | - rule.label && |
191 | | - rule.keywords.some((k) => text.includes(k)) |
192 | | - ) { |
193 | | - detectedLabels.push(rule.label); |
194 | | - } |
195 | | - } |
196 | | -
|
197 | | - // Deduplicate + remove invalid values |
198 | | - const labels = [...new Set(detectedLabels)].filter( |
199 | | - (l) => typeof l === "string" && l.trim().length > 0 |
200 | | - ); |
| 186 | + const labels = rules |
| 187 | + .filter(r => r.label && r.keywords.some(k => text.includes(k))) |
| 188 | + .map(r => r.label) |
| 189 | + .filter(l => typeof l === "string" && l.trim().length > 0); |
201 | 190 |
|
202 | 191 | if (labels.length > 0) { |
| 192 | + console.log("Applying labels:", labels); |
| 193 | +
|
203 | 194 | await github.rest.issues.addLabels({ |
204 | 195 | owner: context.repo.owner, |
205 | 196 | repo: context.repo.repo, |
206 | 197 | issue_number: issue.number, |
207 | 198 | labels, |
208 | 199 | }); |
| 200 | + } else { |
| 201 | + console.log("No labels detected — skipping label API call"); |
209 | 202 | } |
210 | 203 |
|
211 | | - const comment = [ |
212 | | - "👋 **Thanks for opening this issue!**", |
213 | | - "", |
214 | | - "The DevHub maintainers have been notified and will review it ASAP 🚀", |
215 | | - "", |
216 | | - "📌 **Tips to help us help you:**", |
217 | | - "- Clear steps to reproduce (for bugs)", |
218 | | - "- Expected vs actual behavior", |
219 | | - "- Screenshots or logs if applicable", |
220 | | - "", |
221 | | - "Thanks for contributing 💙", |
222 | | - ].join("\n"); |
223 | | -
|
224 | 204 | await github.rest.issues.createComment({ |
225 | 205 | owner: context.repo.owner, |
226 | 206 | repo: context.repo.repo, |
227 | 207 | issue_number: issue.number, |
228 | | - body: comment, |
| 208 | + body: [ |
| 209 | + "👋 **Thanks for opening this issue!**", |
| 210 | + "", |
| 211 | + "Our maintainers have been notified and will review it as soon as possible 🚀", |
| 212 | + "", |
| 213 | + "📌 **To help us resolve this faster:**", |
| 214 | + "- Include clear steps to reproduce (for bugs)", |
| 215 | + "- Mention expected vs actual behavior", |
| 216 | + "- Add screenshots or logs if relevant", |
| 217 | + "", |
| 218 | + "Thanks for contributing to **Open DevHub** 💙", |
| 219 | + ].join("\n"), |
229 | 220 | }); |
0 commit comments