Skip to content

Commit a4a550f

Browse files
Enhance issue handling: auto-assign reviewer and welcome comment on issue open
1 parent 2a17448 commit a4a550f

1 file changed

Lines changed: 80 additions & 50 deletions

File tree

.github/workflows/submission-close.yml

Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,49 @@
1-
name: Submission — Close Guard & Badge Award
1+
name: Auto-assign Badge Submissions
22

33
on:
44
issues:
5-
types: [closed]
5+
types: [opened, closed]
66

77
permissions:
88
issues: write
99

1010
jobs:
11+
# ── On open: assign to @nisalgunawardhana + welcome comment ─────────────────
12+
auto-assign-and-label:
13+
if: github.event.action == 'opened' && contains(toJson(github.event.issue.labels), '"submission"')
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Assign issue to reviewer
17+
uses: actions/github-script@v7
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
script: |
21+
await github.rest.issues.addAssignees({
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
issue_number: context.issue.number,
25+
assignees: ['nisalgunawardhana']
26+
});
27+
28+
- name: Welcome comment
29+
uses: actions/github-script@v7
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
script: |
33+
const username = context.payload.issue.user.login;
34+
await github.rest.issues.createComment({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
issue_number: context.issue.number,
38+
body: `👋 Hey @${username}, thanks for submitting!\n\n` +
39+
`**Status:** Pending Review ⏳\n` +
40+
`**Assigned to:** @nisalgunawardhana\n\n` +
41+
`Your submission will be reviewed shortly. Once approved, your completion badge will be posted here automatically. Hang tight! 🚀`
42+
});
43+
1144
# ── Guard: reopen if closed by anyone other than @nisalgunawardhana ──────────
1245
guard-close:
13-
if: contains(toJson(github.event.issue.labels), '"submission"') && github.event.sender.login != 'nisalgunawardhana'
46+
if: github.event.action == 'closed' && contains(toJson(github.event.issue.labels), '"submission"') && github.event.sender.login != 'nisalgunawardhana'
1447
runs-on: ubuntu-latest
1548
steps:
1649
- name: Reopen issue
@@ -29,75 +62,72 @@ jobs:
2962
owner: context.repo.owner,
3063
repo: context.repo.repo,
3164
issue_number: context.issue.number,
32-
body: `> ⚠️ **This issue was automatically reopened.**
33-
>
34-
> Submission issues can only be closed by [@nisalgunawardhana](https://github.com/nisalgunawardhana) after reviewing your work.
35-
> Please wait for your submission to be reviewed — you'll receive your badge as soon as it's approved!`
65+
body: `> ⚠️ **This issue was automatically reopened.**\n>\n` +
66+
`> Submission issues can only be closed by [@nisalgunawardhana](https://github.com/nisalgunawardhana) after reviewing your work.\n` +
67+
`> Please wait for your submission to be reviewed — you'll receive your badge as soon as it's approved!`
3668
});
3769
3870
# ── Award: post badge + social share when @nisalgunawardhana closes it ───────
3971
award-badge:
40-
if: contains(toJson(github.event.issue.labels), '"submission"') && github.event.sender.login == 'nisalgunawardhana'
72+
if: github.event.action == 'closed' && contains(toJson(github.event.issue.labels), '"submission"') && github.event.sender.login == 'nisalgunawardhana'
4173
runs-on: ubuntu-latest
4274
steps:
4375
- name: Post completion badge and congratulations
4476
uses: actions/github-script@v7
4577
with:
4678
github-token: ${{ secrets.GITHUB_TOKEN }}
4779
script: |
48-
const issueNumber = context.issue.number;
49-
const issueUrl = context.payload.issue.html_url;
50-
const username = context.payload.issue.user.login;
51-
const repoUrl = context.payload.repository.html_url;
80+
const issueNumber = context.issue.number;
81+
const issueUrl = context.payload.issue.html_url;
82+
const username = context.payload.issue.user.login;
83+
const repoUrl = context.payload.repository.html_url;
5284
5385
const badgeMd = `[![GitHub Copilot CLI 101 — Completed](https://img.shields.io/badge/GitHub%20Copilot%20CLI%20101-Completed%20%F0%9F%8E%89-brightgreen?style=for-the-badge&logo=github)](${issueUrl})`;
5486
5587
const tweetText = encodeURIComponent(
56-
`🎉 I just completed the GitHub Copilot CLI 101 course by @nisalgunawardhana!\n\nLevelled up my terminal workflow with GitHub Copilot CLI. Here's my submission:\n${issueUrl}\n\n#GitHubCopilot #DevTools #OpenSource #100DaysOfCode`
88+
`🎉 I just completed GitHub Copilot CLI 101 by @nisalgunawardhana!\n\n` +
89+
`Levelled up my terminal workflow with GitHub Copilot CLI 🚀\n\n` +
90+
`Check it out → ${repoUrl}\n\n` +
91+
`#GitHubCopilot #DevTools #OpenSource #100DaysOfCode`
92+
);
93+
const linkedInText = encodeURIComponent(
94+
`I just completed GitHub Copilot CLI 101 — a hands-on course by @nisalgunawardhana!\n\n` +
95+
`Learned how to use gh copilot explain and gh copilot suggest to supercharge my terminal workflow.\n\n` +
96+
`Check it out and earn your badge too 👇\n${repoUrl}`
5797
);
5898
59-
const linkedInShareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(issueUrl)}`;
60-
const twitterShareUrl = `https://twitter.com/intent/tweet?text=${tweetText}`;
61-
62-
const body = `## 🎉 Congratulations, @${username}!
63-
64-
You've successfully completed **GitHub Copilot CLI 101** and your submission has been reviewed and approved by [@nisalgunawardhana](https://github.com/nisalgunawardhana).
65-
66-
---
67-
68-
### Your Completion Badge
69-
70-
${badgeMd}
71-
72-
Add this to your GitHub profile README or portfolio:
73-
74-
\`\`\`markdown
75-
${badgeMd}
76-
\`\`\`
77-
78-
---
79-
80-
### Share Your Achievement
81-
82-
You put in the work — now show it off! Let your network know you levelled up your dev workflow:
83-
84-
| Platform | Link |
85-
|----------|------|
86-
| 🐦 Twitter / X | [Share on Twitter](${twitterShareUrl}) |
87-
| 💼 LinkedIn | [Share on LinkedIn](${linkedInShareUrl}) |
88-
89-
> **Suggested caption:**
90-
> *"Just completed GitHub Copilot CLI 101! 🚀 Learned how to use \`gh copilot explain\` and \`gh copilot suggest\` to supercharge my terminal workflow. Check it out 👇 ${repoUrl}"*
91-
92-
---
93-
94-
_Reviewed and approved by [@nisalgunawardhana](https://github.com/nisalgunawardhana) · [View submission](${issueUrl})_`;
99+
const twitterUrl = `https://twitter.com/intent/tweet?text=${tweetText}`;
100+
const linkedInUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(issueUrl)}&summary=${linkedInText}`;
101+
102+
const body =
103+
`## 🎉 Congratulations, @${username}!\n\n` +
104+
`Your submission for **GitHub Copilot CLI 101** has been reviewed and approved by [@nisalgunawardhana](https://github.com/nisalgunawardhana).\n\n` +
105+
`---\n\n` +
106+
`### 🏅 Your Completion Badge\n\n` +
107+
`${badgeMd}\n\n` +
108+
`**Copy this to your GitHub profile README or portfolio:**\n\n` +
109+
`\`\`\`markdown\n${badgeMd}\n\`\`\`\n\n` +
110+
`> Replace the badge link with this issue URL: \`${issueUrl}\`\n\n` +
111+
`---\n\n` +
112+
`### 📣 Share Your Achievement!\n\n` +
113+
`You put in the work — show it off and inspire others!\n\n` +
114+
`| | Platform | Suggested tag |\n` +
115+
`|---|---|---|\n` +
116+
`| 🐦 | [Share on Twitter / X](${twitterUrl}) | Tag **@nisalgunawardhana** |\n` +
117+
`| 💼 | [Share on LinkedIn](${linkedInUrl}) | Mention **@nisalgunawardhana** |\n\n` +
118+
`> **Caption idea:** *"Just completed GitHub Copilot CLI 101 by @nisalgunawardhana! 🚀 Learned how to use \`gh copilot explain\` & \`gh copilot suggest\` to supercharge my terminal. Check it out 👇 ${repoUrl} #GitHubCopilot #DevTools"*\n\n` +
119+
`---\n\n` +
120+
`### 🔔 Want more learning opportunities?\n\n` +
121+
`Follow [@nisalgunawardhana on GitHub](https://github.com/nisalgunawardhana) to get notified when new courses and hands-on workshops drop!\n\n` +
122+
`[![Follow on GitHub](https://img.shields.io/github/followers/nisalgunawardhana?label=Follow%20%40nisalgunawardhana&style=social)](https://github.com/nisalgunawardhana)\n\n` +
123+
`---\n\n` +
124+
`_Reviewed and approved by [@nisalgunawardhana](https://github.com/nisalgunawardhana) · [View submission #${issueNumber}](${issueUrl})_`;
95125
96126
await github.rest.issues.createComment({
97127
owner: context.repo.owner,
98128
repo: context.repo.repo,
99129
issue_number: issueNumber,
100-
body: body.replace(/^ /gm, '')
130+
body
101131
});
102132
103133
await github.rest.issues.addLabels({

0 commit comments

Comments
 (0)