Application: Test Applicant #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Application to Notion | |
| on: | |
| issues: | |
| types: [opened] | |
| jobs: | |
| sync: | |
| if: contains(github.event.issue.labels.*.name, 'application') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Parse application fields | |
| id: parse | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = context.payload.issue.body || ''; | |
| function extractField(body, label) { | |
| const regex = new RegExp(`### ${label}\\s*\\n\\s*([\\s\\S]*?)(?=\\n### |$)`, 'i'); | |
| const match = body.match(regex); | |
| return match ? match[1].trim() : ''; | |
| } | |
| const name = extractField(body, 'Name'); | |
| const email = extractField(body, 'Email'); | |
| const linkedin = extractField(body, 'LinkedIn'); | |
| const submission = extractField(body, 'Your submission'); | |
| core.setOutput('name', name); | |
| core.setOutput('email', email); | |
| core.setOutput('linkedin', linkedin); | |
| core.setOutput('submission', submission); | |
| - name: Create Notion page | |
| uses: actions/github-script@v7 | |
| env: | |
| NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }} | |
| NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }} | |
| APP_NAME: ${{ steps.parse.outputs.name }} | |
| APP_EMAIL: ${{ steps.parse.outputs.email }} | |
| APP_LINKEDIN: ${{ steps.parse.outputs.linkedin }} | |
| APP_SUBMISSION: ${{ steps.parse.outputs.submission }} | |
| ISSUE_URL: ${{ github.event.issue.html_url }} | |
| with: | |
| script: | | |
| const submission = (process.env.APP_SUBMISSION || '').slice(0, 2000); | |
| const response = await fetch('https://api.notion.com/v1/pages', { | |
| method: 'POST', | |
| headers: { | |
| 'Authorization': `Bearer ${process.env.NOTION_API_KEY}`, | |
| 'Content-Type': 'application/json', | |
| 'Notion-Version': '2022-06-28' | |
| }, | |
| body: JSON.stringify({ | |
| parent: { database_id: process.env.NOTION_DATABASE_ID }, | |
| properties: { | |
| 'Name': { title: [{ text: { content: process.env.APP_NAME || 'Unknown' } }] }, | |
| 'Email': { email: process.env.APP_EMAIL || null }, | |
| 'Role': { select: { name: 'GTM Engineer' } }, | |
| 'LinkedIn': { url: process.env.APP_LINKEDIN || null }, | |
| 'GitHub Issue': { url: process.env.ISSUE_URL }, | |
| 'Status': { select: { name: 'New' } } | |
| }, | |
| children: [ | |
| { | |
| object: 'block', | |
| type: 'heading_2', | |
| heading_2: { rich_text: [{ type: 'text', text: { content: 'Submission' } }] } | |
| }, | |
| { | |
| object: 'block', | |
| type: 'paragraph', | |
| paragraph: { rich_text: [{ type: 'text', text: { content: submission } }] } | |
| } | |
| ] | |
| }) | |
| }); | |
| if (!response.ok) { | |
| const err = await response.text(); | |
| core.setFailed(`Notion API error: ${response.status} ${err}`); | |
| } | |
| - name: Notify Slack | |
| if: success() | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| APP_NAME: ${{ steps.parse.outputs.name }} | |
| ISSUE_URL: ${{ github.event.issue.html_url }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| if (!process.env.SLACK_WEBHOOK_URL) return; | |
| await fetch(process.env.SLACK_WEBHOOK_URL, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| text: `New agent application for *GTM Engineer*: ${process.env.APP_NAME}\n<${process.env.ISSUE_URL}|View on GitHub>` | |
| }) | |
| }); | |
| - name: Comment on issue | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `Thanks for applying! Your application has been received and sent to our Head of Growth. We'll be in touch.\n\n— Every` | |
| }); |