Edit data for **PCD @ Shanghai** #421
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: 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 | |
| env: | |
| STATUS_COMMENT_MARKER: <!-- new-event-intake-status --> | |
| jobs: | |
| process-new-event: | |
| 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 }} | |
| outputs: | |
| valid: ${{ steps.generate.outputs.valid }} | |
| branch: ${{ steps.generate.outputs.branch }} | |
| commit_message: ${{ steps.generate.outputs.commit_message }} | |
| pr_title: ${{ steps.generate.outputs.pr_title }} | |
| pr_body_path: ${{ steps.generate.outputs.pr_body_path }} | |
| validation_comment_path: ${{ steps.generate.outputs.validation_comment_path }} | |
| event_name: ${{ steps.generate.outputs.event_name }} | |
| pr_label: ${{ steps.generate.outputs.pr_label }} | |
| action_verb: ${{ steps.generate.outputs.action_verb }} | |
| steps: | |
| - name: Log trigger context | |
| run: | | |
| echo "event_action=${{ github.event.action }}" | |
| echo "issue_number=${{ github.event.issue.number }}" | |
| echo "issue_labels=${{ join(github.event.issue.labels.*.name, ', ') }}" | |
| echo "sender=${{ github.event.sender.login }}" | |
| - 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: Install script dependencies | |
| run: npm install --prefix /tmp/script-deps open-location-code | |
| - 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 "event_name=${{ steps.generate.outputs.event_name }}" | |
| echo "validation_comment_path=${{ steps.generate.outputs.validation_comment_path }}" | |
| echo "pr_body_path=${{ steps.generate.outputs.pr_body_path }}" | |
| - name: Log PR body | |
| if: steps.generate.outputs.valid == 'true' | |
| run: cat "${{ steps.generate.outputs.pr_body_path }}" | |
| - name: Log validation comment | |
| if: steps.generate.outputs.valid == 'false' | |
| run: cat "${{ steps.generate.outputs.validation_comment_path }}" | |
| - name: Upload event files artifact | |
| if: steps.generate.outputs.valid == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: event-files-${{ github.event.issue.number }} | |
| path: pcd-website/src/content/events/ | |
| retention-days: 1 | |
| - name: Upload PR body artifact | |
| if: steps.generate.outputs.valid == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-body-${{ github.event.issue.number }} | |
| path: ${{ steps.generate.outputs.pr_body_path }} | |
| retention-days: 1 | |
| - name: Upload validation comment artifact | |
| if: steps.generate.outputs.valid == 'false' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validation-comment-${{ github.event.issue.number }} | |
| path: ${{ steps.generate.outputs.validation_comment_path }} | |
| retention-days: 1 | |
| process-edit-event: | |
| if: contains(github.event.issue.labels.*.name, 'edit event') | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| env: | |
| PCD_TEAM_ASSIGNEES: ${{ vars.PCD_TEAM_ASSIGNEES }} | |
| PCD_TEAM_REVIEWERS: ${{ vars.PCD_TEAM_REVIEWERS }} | |
| outputs: | |
| event_url: ${{ steps.generate.outputs.event_url }} | |
| valid: ${{ steps.generate.outputs.valid }} | |
| branch: ${{ steps.generate.outputs.branch }} | |
| commit_message: ${{ steps.generate.outputs.commit_message }} | |
| pr_title: ${{ steps.generate.outputs.pr_title }} | |
| pr_body_path: ${{ steps.generate.outputs.pr_body_path }} | |
| validation_comment_path: ${{ steps.generate.outputs.validation_comment_path }} | |
| event_name: ${{ steps.generate.outputs.event_name }} | |
| pr_label: ${{ steps.generate.outputs.pr_label }} | |
| action_verb: ${{ steps.generate.outputs.action_verb }} | |
| steps: | |
| - name: Log trigger context | |
| run: | | |
| echo "event_action=${{ github.event.action }}" | |
| echo "issue_number=${{ github.event.issue.number }}" | |
| echo "issue_labels=${{ join(github.event.issue.labels.*.name, ', ') }}" | |
| echo "sender=${{ github.event.sender.login }}" | |
| - 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: 'edit event', color: '0075ca', description: 'Edit 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: Install script dependencies | |
| run: npm install --prefix /tmp/script-deps open-location-code | |
| - name: Generate event files from issue | |
| id: generate | |
| run: node .github/scripts/process-edit-event-issue.mjs | |
| - name: Log generate outputs | |
| if: always() | |
| run: | | |
| echo "valid=${{ steps.generate.outputs.valid }}" | |
| echo "branch=${{ steps.generate.outputs.branch }}" | |
| echo "event_name=${{ steps.generate.outputs.event_name }}" | |
| echo "validation_comment_path=${{ steps.generate.outputs.validation_comment_path }}" | |
| echo "pr_body_path=${{ steps.generate.outputs.pr_body_path }}" | |
| - name: Log PR body | |
| if: steps.generate.outputs.valid == 'true' | |
| run: cat "${{ steps.generate.outputs.pr_body_path }}" | |
| - name: Log validation comment | |
| if: steps.generate.outputs.valid == 'false' | |
| run: cat "${{ steps.generate.outputs.validation_comment_path }}" | |
| - name: Upload event files artifact | |
| if: steps.generate.outputs.valid == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: event-files-${{ github.event.issue.number }} | |
| path: pcd-website/src/content/events/ | |
| retention-days: 1 | |
| - name: Upload PR body artifact | |
| if: steps.generate.outputs.valid == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-body-${{ github.event.issue.number }} | |
| path: ${{ steps.generate.outputs.pr_body_path }} | |
| retention-days: 1 | |
| - name: Upload validation comment artifact | |
| if: steps.generate.outputs.valid == 'false' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validation-comment-${{ github.event.issue.number }} | |
| path: ${{ steps.generate.outputs.validation_comment_path }} | |
| retention-days: 1 | |
| handle-validation-failure: | |
| needs: [process-new-event, process-edit-event] | |
| if: | | |
| always() && ( | |
| (needs.process-new-event.result != 'skipped' && ( | |
| needs.process-new-event.result == 'failure' || | |
| needs.process-new-event.outputs.valid == 'false' | |
| )) || | |
| (needs.process-edit-event.result != 'skipped' && ( | |
| needs.process-edit-event.result == 'failure' || | |
| needs.process-edit-event.outputs.valid == 'false' | |
| )) | |
| ) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Download validation comment artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: validation-comment-${{ github.event.issue.number }} | |
| path: /tmp/validation-comment | |
| - name: Upsert validation status comment | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = process.env.STATUS_COMMENT_MARKER; | |
| const commentPath = `/tmp/validation-comment/validation-${context.issue.number}.md`; | |
| const body = `${marker}\n${fs.readFileSync(commentPath, '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, | |
| }); | |
| } | |
| create-pr: | |
| needs: [process-new-event, process-edit-event] | |
| if: | | |
| always() && ( | |
| (needs.process-new-event.result != 'skipped' && needs.process-new-event.outputs.valid == 'true') || | |
| (needs.process-edit-event.result != 'skipped' && needs.process-edit-event.outputs.valid == 'true') | |
| ) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }} | |
| pull-request-url: ${{ steps.create_pr.outputs.pull-request-url }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| - name: Download event files artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: event-files-${{ github.event.issue.number }} | |
| path: pcd-website/src/content/events/ | |
| - name: Download PR body artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pr-body-${{ github.event.issue.number }} | |
| path: /tmp/pr-body | |
| - name: Log resolved PR inputs | |
| run: | | |
| echo "branch=${{ needs.process-new-event.outputs.branch || needs.process-edit-event.outputs.branch }}" | |
| echo "title=${{ needs.process-new-event.outputs.pr_title || needs.process-edit-event.outputs.pr_title }}" | |
| echo "body_path=/tmp/pr-body/pr-body-${{ github.event.issue.number }}.md" | |
| cat "/tmp/pr-body/pr-body-${{ github.event.issue.number }}.md" | |
| - name: Create pull request | |
| id: create_pr | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ needs.process-new-event.outputs.branch || needs.process-edit-event.outputs.branch }} | |
| delete-branch: true | |
| add-paths: | | |
| pcd-website/src/content/events/** | |
| commit-message: ${{ needs.process-new-event.outputs.commit_message || needs.process-edit-event.outputs.commit_message }} | |
| title: ${{ needs.process-new-event.outputs.pr_title || needs.process-edit-event.outputs.pr_title }} | |
| body-path: /tmp/pr-body/pr-body-${{ github.event.issue.number }}.md | |
| - name: Log create-pr outputs | |
| if: always() | |
| run: | | |
| echo "pull-request-number=${{ steps.create_pr.outputs.pull-request-number }}" | |
| echo "pull-request-url=${{ steps.create_pr.outputs.pull-request-url }}" | |
| - name: Explain unchanged event edit | |
| if: >- | |
| success() && needs.process-edit-event.outputs.valid == 'true' && | |
| steps.create_pr.outputs.pull-request-operation == 'none' && | |
| steps.create_pr.outputs.pull-request-number == '' | |
| uses: actions/github-script@v8 | |
| env: | |
| EVENT_URL: ${{ needs.process-edit-event.outputs.event_url }} | |
| with: | |
| script: | | |
| const marker = process.env.STATUS_COMMENT_MARKER; | |
| const body = [ | |
| marker, | |
| `Your edits match the [event data already on the site](${process.env.EVENT_URL}), so no pull request was created.`, | |
| '', | |
| 'If you meant to change something, edit this issue with your desired changes. It will be processed again automatically.', | |
| '', | |
| '> [!NOTE]', | |
| '> We’re aware of [an issue](https://discourse.processing.org/t/pcd-worldwide-2026/48081/75) that prevents changes to existing data when first submitting through the "edit event" issue template. To work around it, please edit the issue above rather than creating a new one.', | |
| ].join('\n'); | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, repo, issue_number, | |
| }); | |
| const existing = comments.find((comment) => | |
| comment.user?.type === 'Bot' && comment.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner, repo, comment_id: existing.id, body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | |
| } | |
| post-pr-actions: | |
| needs: [process-new-event, process-edit-event, create-pr] | |
| if: always() && needs.create-pr.outputs.pull-request-number != '' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| env: | |
| PCD_TEAM_REVIEWERS: ${{ vars.PCD_TEAM_REVIEWERS }} | |
| steps: | |
| - name: Label pull request | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = Number('${{ needs.create-pr.outputs.pull-request-number }}'); | |
| const prLabel = '${{ needs.process-new-event.outputs.pr_label || needs.process-edit-event.outputs.pr_label }}'; | |
| const desiredLabels = [ | |
| { name: 'needs review', color: 'fbca04', description: 'Submission is ready for maintainer review' }, | |
| { name: prLabel, color: prLabel === 'new event' ? '0e8a16' : '0075ca', description: prLabel === 'new event' ? 'New event submission intake' : 'Edit 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: 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('${{ needs.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 | |
| uses: actions/github-script@v8 | |
| env: | |
| PR_NUMBER: ${{ needs.create-pr.outputs.pull-request-number }} | |
| PR_URL: ${{ needs.create-pr.outputs.pull-request-url }} | |
| EVENT_NAME: ${{ needs.process-new-event.outputs.event_name || needs.process-edit-event.outputs.event_name }} | |
| ACTION_VERB: ${{ needs.process-new-event.outputs.action_verb || needs.process-edit-event.outputs.action_verb }} | |
| with: | |
| script: | | |
| const marker = process.env.STATUS_COMMENT_MARKER; | |
| const body = [ | |
| marker, | |
| `**${process.env.EVENT_NAME}** has been successfully parsed and a pull request has been opened for review: [#${process.env.PR_NUMBER}](${process.env.PR_URL}).`, | |
| '', | |
| `Once the PR is merged, your event will be **${process.env.ACTION_VERB}** the map at https://day.processing.org.`, | |
| ].join('\n'); | |
| 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, | |
| }); | |
| } |