Docs/event marketing library #9494
Workflow file for this run
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: PR Auto Assign & GSSoC Label | |
| on: | |
| pull_request_target: | |
| types: [opened] | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| assign-and-label: | |
| name: Assign PR to author & add GSSoC label | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Assign PR to creator and add gssoc:approved label | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const prNum = pr.number; | |
| const author = pr.user.login; | |
| const repo = { owner: context.repo.owner, repo: context.repo.repo }; | |
| // ── 1. Ensure gssoc:approved label exists ─────────────────────── | |
| const LABEL_NAME = 'gssoc:approved'; | |
| const LABEL_COLOR = '7B2D8B'; // deep purple — GSSoC brand | |
| const LABEL_DESC = 'Approved contribution for GSSoC'; | |
| try { | |
| await github.rest.issues.getLabel({ ...repo, name: LABEL_NAME }); | |
| } catch (err) { | |
| if (err.status !== 404) throw err; | |
| await github.rest.issues.createLabel({ | |
| ...repo, | |
| name: LABEL_NAME, | |
| color: LABEL_COLOR, | |
| description: LABEL_DESC, | |
| }); | |
| console.log(`✅ Created label: ${LABEL_NAME}`); | |
| } | |
| // ── 2. Assign PR to its author ────────────────────────────────── | |
| try { | |
| await github.rest.issues.addAssignees({ | |
| ...repo, | |
| issue_number: prNum, | |
| assignees: [author], | |
| }); | |
| console.log(`👤 Assigned PR #${prNum} to @${author}`); | |
| } catch (err) { | |
| console.error(`❌ Failed to assign PR #${prNum}: ${err.message}`); | |
| } | |
| // ── 3. Add gssoc:approved label ───────────────────────────────── | |
| try { | |
| await github.rest.issues.addLabels({ | |
| ...repo, | |
| issue_number: prNum, | |
| labels: [LABEL_NAME], | |
| }); | |
| console.log(`🏷 Applied label "${LABEL_NAME}" to PR #${prNum}`); | |
| } catch (err) { | |
| console.error(`❌ Failed to add label to PR #${prNum}: ${err.message}`); | |
| } |