Test event #14
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: New Event Intake | |
| on: | |
| issues: | |
| types: [opened, edited, reopened, labeled] | |
| concurrency: | |
| group: new-event-intake-${{ github.event.issue.number }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| create-event-pr: | |
| if: contains(github.event.issue.labels.*.name, 'new event') | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| env: | |
| PCD_TEAM_ASSIGNEES: ${{ vars.PCD_TEAM_ASSIGNEES }} | |
| PCD_TEAM_REVIEWERS: ${{ vars.PCD_TEAM_REVIEWERS }} | |
| STATUS_COMMENT_MARKER: <!-- new-event-intake-status --> | |
| steps: | |
| - name: Label and assign intake issue | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = context.issue.number; | |
| const desiredLabels = [ | |
| { name: 'needs review', color: 'fbca04', description: 'Submission is ready for maintainer review' }, | |
| { name: 'new event', color: '0e8a16', description: 'New event submission intake' }, | |
| ]; | |
| for (const label of desiredLabels) { | |
| try { | |
| await github.rest.issues.getLabel({ owner, repo, name: label.name }); | |
| } catch (error) { | |
| if (error.status !== 404) throw error; | |
| await github.rest.issues.createLabel({ owner, repo, ...label }); | |
| } | |
| } | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number, | |
| labels: desiredLabels.map((label) => label.name), | |
| }); | |
| const assignees = (process.env.PCD_TEAM_ASSIGNEES || '') | |
| .split(',') | |
| .map((value) => value.trim()) | |
| .filter(Boolean); | |
| if (assignees.length) { | |
| await github.rest.issues.addAssignees({ | |
| owner, | |
| repo, | |
| issue_number, | |
| assignees, | |
| }); | |
| } | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| persist-credentials: false | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| - name: Generate event files from issue | |
| id: generate | |
| run: node .github/scripts/process-new-event-issue.mjs | |
| - name: Log generate outputs | |
| if: always() | |
| run: | | |
| echo "valid=${{ steps.generate.outputs.valid }}" | |
| echo "branch=${{ steps.generate.outputs.branch }}" | |
| echo "validation_comment_path=${{ steps.generate.outputs.validation_comment_path }}" | |
| echo "pr_body_path=${{ steps.generate.outputs.pr_body_path }}" | |
| - name: Upsert validation status comment | |
| if: steps.generate.outputs.valid == 'false' | |
| uses: actions/github-script@v8 | |
| env: | |
| VALIDATION_COMMENT_PATH: ${{ steps.generate.outputs.validation_comment_path }} | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = process.env.STATUS_COMMENT_MARKER; | |
| const body = `${marker}\n${fs.readFileSync(process.env.VALIDATION_COMMENT_PATH, 'utf8')}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find((comment) => | |
| comment.user?.type === 'Bot' && | |
| comment.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } | |
| - name: Create pull request | |
| if: steps.generate.outputs.valid == 'true' | |
| id: create_pr | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ steps.generate.outputs.branch }} | |
| delete-branch: true | |
| add-paths: | | |
| pcd-website/src/content/events/** | |
| commit-message: ${{ steps.generate.outputs.commit_message }} | |
| title: ${{ steps.generate.outputs.pr_title }} | |
| body-path: ${{ steps.generate.outputs.pr_body_path }} | |
| - name: Label pull request | |
| if: steps.generate.outputs.valid == 'true' && steps.create_pr.outputs.pull-request-number != '' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = Number('${{ steps.create_pr.outputs.pull-request-number }}'); | |
| const desiredLabels = [ | |
| { name: 'needs review', color: 'fbca04', description: 'Submission is ready for maintainer review' }, | |
| { name: 'new event', color: '0e8a16', description: 'New event submission intake' }, | |
| ]; | |
| for (const label of desiredLabels) { | |
| try { | |
| await github.rest.issues.getLabel({ owner, repo, name: label.name }); | |
| } catch (error) { | |
| if (error.status !== 404) throw error; | |
| await github.rest.issues.createLabel({ owner, repo, ...label }); | |
| } | |
| } | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number, | |
| labels: desiredLabels.map((label) => label.name), | |
| }); | |
| - name: Request team review | |
| if: steps.generate.outputs.valid == 'true' && steps.create_pr.outputs.pull-request-number != '' && env.PCD_TEAM_REVIEWERS != '' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const pull_number = Number('${{ steps.create_pr.outputs.pull-request-number }}'); | |
| const team_reviewers = (process.env.PCD_TEAM_REVIEWERS || '') | |
| .split(',') | |
| .map((value) => value.trim()) | |
| .filter(Boolean); | |
| if (team_reviewers.length) { | |
| await github.rest.pulls.requestReviewers({ | |
| owner, | |
| repo, | |
| pull_number, | |
| team_reviewers, | |
| }); | |
| } | |
| - name: Upsert pull request status comment | |
| if: steps.generate.outputs.valid == 'true' && steps.create_pr.outputs.pull-request-number != '' | |
| uses: actions/github-script@v8 | |
| env: | |
| PR_NUMBER: ${{ steps.create_pr.outputs.pull-request-number }} | |
| PR_URL: ${{ steps.create_pr.outputs.pull-request-url }} | |
| with: | |
| script: | | |
| const marker = process.env.STATUS_COMMENT_MARKER; | |
| const body = `${marker}\nA pull request has been opened for this submission: #${process.env.PR_NUMBER} (${process.env.PR_URL}).`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find((comment) => | |
| comment.user?.type === 'Bot' && | |
| comment.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } |