11name : Guest Welcome Bot
22
33on :
4- issues :
4+ issues :
55 types : [labeled]
66 workflow_dispatch :
77 inputs :
@@ -22,32 +22,32 @@ jobs:
2222 - name : Setup Node.js
2323 uses : actions/setup-node@v4
2424 with :
25- node-version : ' 22'
25+ node-version : ' 22'
2626
27- - name : Install Copilot CLI and SDK
27+ - name : Install Copilot CLI and SDK
2828 run : |
2929 npm install -g @github/copilot
3030 npm install @github/copilot-sdk
3131
3232 - name : Get issue data
3333 id : get-issue
34- uses : actions/github-script@v7
34+ uses : actions/github-script@v7
3535 with :
36- script : |
36+ script : |
3737 let issueNumber;
3838 let issue;
3939
4040 if (context.eventName === 'workflow_dispatch') {
41- issueNumber = ${{ github.event.inputs.issue_number || 0 }};
41+ issueNumber = ${{ github. event.inputs.issue_number || 0 }};
4242 const response = await github.rest.issues.get({
4343 owner: context.repo.owner,
4444 repo: context.repo.repo,
4545 issue_number: issueNumber
4646 });
4747 issue = response.data;
4848 } else {
49- issue = context.payload.issue;
50- issueNumber = issue. number;
49+ issue = context.payload. issue;
50+ issueNumber = issue.number;
5151 }
5252
5353 core.setOutput('issue_number', issueNumber);
@@ -56,18 +56,19 @@ jobs:
5656 - name : Generate personalized prep
5757 id : personalize
5858 env :
59- GH_TOKEN : ${{ secrets.COPILOT_PAT }}
60- ISSUE_BODY : ${{ steps. get-issue.outputs.issue_body }}
59+ GH_TOKEN : ${{ secrets.COPILOT_PAT }}
60+ ISSUE_BODY : ${{ steps.get-issue.outputs.issue_body }}
6161 run : |
62- cat << 'EOF ' > generate-welcome. mjs
62+ cat << 'SCRIPT ' > generate-welcome.mjs
6363 import { CopilotClient } from '@github/copilot-sdk';
64+ import { appendFileSync } from 'fs';
6465
6566 const body = process.env.ISSUE_BODY || '';
6667
67- const nameMatch = body.match(/Name\s*\n\s*([^\n]+)/);
68+ const nameMatch = body. match(/Name\s*\n\s*([^\n]+)/);
6869 const projectMatch = body.match(/Project Name\s*\n\s*([^\n]+)/);
6970 const repoMatch = body.match(/Project Repo Link\s*\n\s*([^\n]+)/);
70- const descMatch = body.match(/Tell us about yourself\s*\n\s*([\s\S]*?)(?=\n###|\n##|$)/);
71+ const descMatch = body. match(/Tell us about yourself\s*\n\s*([\s\S]*?)(?=\n###|\n##|$)/);
7172
7273 const guestName = nameMatch ? nameMatch[1].trim() : 'Guest';
7374 const projectName = projectMatch ? projectMatch[1].trim() : 'their project';
8182 Project Repo: ${projectRepo}
8283 Guest Background: ${guestBackground}
8384
84- Write a warm, encouraging message that acknowledges their specific project and shows genuine excitement to have them on the stream. Keep it concise and authentic. Do not use markdown formatting or special characters. `;
85+ Write a warm, encouraging message that acknowledges their specific project and shows genuine excitement to have them on the stream. Keep it concise and authentic. Do not use markdown formatting or special characters. `;
8586
8687 let personalizedMessage = '';
8788 let client;
9192 await client.start();
9293
9394 const session = await client.createSession({ model: 'gpt-5' });
94- const response = await session. sendAndWait({ prompt });
95+ const response = await session.sendAndWait({ prompt });
9596
9697 if (response?.data?. content) {
9798 personalizedMessage = response.data.content;
@@ -102,37 +103,35 @@ jobs:
102103 await session.destroy();
103104
104105 } catch (error) {
105- console.error('Copilot SDK error:', error.message);
106+ console.error('Copilot SDK error:', error. message);
106107 personalizedMessage = `We are thrilled to have ${guestName} joining us to talk about ${projectName}! This is going to be a fantastic session.`;
107108
108109 } finally {
109110 if (client) {
110- await client. stop().catch(e => console.error('Cleanup error:', e.message));
111+ await client.stop().catch(e => console.error('Cleanup error:', e.message));
111112 }
112113 }
113114
114- // Output for GitHub Actions
115- const fs = await import('fs');
116115 const outputFile = process.env.GITHUB_OUTPUT;
117- fs. appendFileSync(outputFile, `personalized_message<<EOFMSG\n${personalizedMessage}\nEOFMSG\n`);
118- fs. appendFileSync(outputFile, `guest_name=${guestName}\n`);
119- EOF
116+ appendFileSync(outputFile, `personalized_message<<EOFMSG\n${personalizedMessage}\nEOFMSG\n`);
117+ appendFileSync(outputFile, `guest_name=${guestName}\n`);
118+ SCRIPT
120119
121120 node generate-welcome.mjs
122121
123122 - name : Post personalized prep comment
124123 uses : actions/github-script@v7
125124 env :
126- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
127- PERSONALIZED_MESSAGE : ${{ steps.personalize. outputs.personalized_message }}
125+ GITHUB_TOKEN : ${{ secrets. GITHUB_TOKEN }}
126+ PERSONALIZED_MESSAGE : ${{ steps.personalize.outputs.personalized_message }}
128127 GUEST_NAME : ${{ steps.personalize.outputs.guest_name }}
129- ISSUE_NUMBER : ${{ steps.get-issue.outputs.issue_number }}
130- with :
131- script : |
132- const personalizedMessage = process.env.PERSONALIZED_MESSAGE;
128+ ISSUE_NUMBER : ${{ steps.get-issue.outputs. issue_number }}
129+ with :
130+ script : |
131+ const personalizedMessage = process.env. PERSONALIZED_MESSAGE;
133132 const guestName = process.env.GUEST_NAME;
134- const issueNumber = parseInt(process.env. ISSUE_NUMBER, 10);
135- const repoUrl = context. payload.repository.html_url;
133+ const issueNumber = parseInt(process.env.ISSUE_NUMBER, 10);
134+ const repoUrl = context.payload.repository. html_url;
136135 const guideUrl = repoUrl + '/blob/main/admin/approved-guest.md';
137136
138137 const comment = [
0 commit comments