|
| 1 | +name: Scheduled Guest & Host Notifications |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + notify-guest: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + if: github.event.label.name == 'scheduled' |
| 11 | + steps: |
| 12 | + - name: Notify guest with schedule and prep guide |
| 13 | + uses: actions/github-script@v7 |
| 14 | + with: |
| 15 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 16 | + script: | |
| 17 | + const githubHandle = context.payload.issue.user.login; |
| 18 | +
|
| 19 | + console.log('Processing issue #', context.issue.number, 'by author:', githubHandle); |
| 20 | +
|
| 21 | + if (!githubHandle) { |
| 22 | + console.log('No GitHub handle found for issue #', context.issue.number); |
| 23 | + return; |
| 24 | + } |
| 25 | +
|
| 26 | + const isValidGitHubHandle = (handle) => { |
| 27 | + if (!handle || typeof handle !== 'string') return false; |
| 28 | + if (handle.length < 1 || handle.length > 39) return false; |
| 29 | + return /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$|^[a-zA-Z0-9]$/.test(handle); |
| 30 | + }; |
| 31 | +
|
| 32 | + if (!isValidGitHubHandle(githubHandle)) { |
| 33 | + console.log('Handle validation failed for issue #', context.issue.number); |
| 34 | + return; |
| 35 | + } |
| 36 | +
|
| 37 | + const safeHandle = githubHandle.replace(/[<>'"&]/g, ''); |
| 38 | +
|
| 39 | + const commentBody = [ |
| 40 | + `Hey @${safeHandle} ✨`, |
| 41 | + '', |
| 42 | + "You're officially scheduled for **Open Source Friday**! 🚀🎥", |
| 43 | + '', |
| 44 | + 'The stream starts at **1:00 PM ET**. Please join at **12:45 PM ET** for prep and tech checks. Be ready with your demo—our audience strongly prefers technical demos.', |
| 45 | + '', |
| 46 | + 'Here are some guidelines on preparing for the live stream:', |
| 47 | + '', |
| 48 | + '[Preparation Instructions](https://github.com/githubevents/open-source-friday/blob/main/admin/guest-assets/Streaming-Guide.md)', |
| 49 | + '', |
| 50 | + 'Let us know if you have any questions!', |
| 51 | + '', |
| 52 | + 'Kedasha, Andrea & Kevin 👯', |
| 53 | + ].join('\n'); |
| 54 | +
|
| 55 | + try { |
| 56 | + const result = await github.rest.issues.createComment({ |
| 57 | + owner: context.repo.owner, |
| 58 | + repo: context.repo.repo, |
| 59 | + issue_number: context.issue.number, |
| 60 | + body: commentBody, |
| 61 | + }); |
| 62 | + console.log('Guest notification created, ID:', result.data.id); |
| 63 | + } catch (error) { |
| 64 | + console.error('Failed to create guest comment for issue #', context.issue.number); |
| 65 | + } |
| 66 | +
|
| 67 | + remind-hosts: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + if: github.event.label.name == 'scheduled' |
| 70 | + steps: |
| 71 | + - name: Post host checklist |
| 72 | + uses: actions/github-script@v7 |
| 73 | + with: |
| 74 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + script: | |
| 76 | + const commentBody = [ |
| 77 | + 'Hi @LadyKerr, @AndreaGriffiths11, and @KevinCrosby,', |
| 78 | + '', |
| 79 | + 'This stream has been scheduled. Please complete the following tasks:', |
| 80 | + '', |
| 81 | + '- [ ] Create social card', |
| 82 | + '- [ ] Create meetup link', |
| 83 | + '- [ ] Create and schedule twitch stream (LinkedIn, Twitch, YouTube)', |
| 84 | + '- [ ] Schedule social media post (Twitter)', |
| 85 | + '- [ ] Send prep doc to guests', |
| 86 | + '', |
| 87 | + 'You can find the instructions in this [guide](https://github.com/githubevents/open-source-friday/blob/main/admin/guest-assets/Streaming-Guide.md).', |
| 88 | + ].join('\n'); |
| 89 | +
|
| 90 | + await github.rest.issues.createComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + issue_number: context.issue.number, |
| 94 | + body: commentBody, |
| 95 | + }); |
0 commit comments