|
| 1 | +name: Setup GSSOC Labels |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - '.github/workflows/labels-setup.yml' |
| 10 | + |
| 11 | +jobs: |
| 12 | + setup-labels: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Create or Update Labels |
| 16 | + uses: actions/github-script@v6 |
| 17 | + with: |
| 18 | + script: | |
| 19 | + const labels = [ |
| 20 | + // QUALITY (OPTIONAL) - Teal |
| 21 | + { name: "quality:clean", color: "c5f0ed", description: "PR follows all coding standards and is well-structured (for GSSoC'26)" }, |
| 22 | + { name: "quality:exceptional", color: "c5f0ed", description: "PR goes above and beyond in terms of quality and optimization (for GSSoC'26)" }, |
| 23 | + |
| 24 | + // TYPE BONUS (OPTIONAL) - Gray |
| 25 | + { name: "type:docs", color: "f1f2f6", description: "Additions or updates to documentation (for GSSoC'26)" }, |
| 26 | + { name: "type:testing", color: "f1f2f6", description: "Adding or improving tests (for GSSoC'26)" }, |
| 27 | + { name: "type:accessibility", color: "f1f2f6", description: "Improvements related to web accessibility (for GSSoC'26)" }, |
| 28 | + { name: "type:performance", color: "f1f2f6", description: "Changes that improve speed or resource usage (for GSSoC'26)" }, |
| 29 | + { name: "type:security", color: "f1f2f6", description: "Security-related fixes or enhancements (for GSSoC'26)" }, |
| 30 | + { name: "type:design", color: "f1f2f6", description: "Changes to UI, layout, or visual elements (for GSSoC'26)" }, |
| 31 | + { name: "type:refactor", color: "f1f2f6", description: "Code changes that neither fix a bug nor add a feature (for GSSoC'26)" }, |
| 32 | + { name: "type:devops", color: "f1f2f6", description: "Changes to CI/CD, build scripts, or infrastructure (for GSSoC'26)" }, |
| 33 | + { name: "type:bug", color: "f1f2f6", description: "Fixes for identified issues or errors (for GSSoC'26)" }, |
| 34 | + { name: "type:feature", color: "f1f2f6", description: "Introduction of new functionality (for GSSoC'26)" }, |
| 35 | + |
| 36 | + // VALIDATION (ADMIN DECIDES) |
| 37 | + { name: "gssoc:approved", color: "c5f0ed", description: "PR has been reviewed and is eligible for GSSoC points (for GSSoC'26)" }, |
| 38 | + { name: "gssoc:invalid", color: "ffcccb", description: "PR does not meet requirements or is out of scope (for GSSoC'26)" }, |
| 39 | + { name: "gssoc:spam", color: "ffcccb", description: "PR is low-effort or automated spam (for GSSoC'26)" }, |
| 40 | + { name: "gssoc:ai-slop", color: "ffcccb", description: "PR contains low-quality AI-generated content (for GSSoC'26)" }, |
| 41 | + ]; |
| 42 | +
|
| 43 | + for (const label of labels) { |
| 44 | + try { |
| 45 | + const { data: existingLabel } = await github.rest.issues.getLabel({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + name: label.name |
| 49 | + }); |
| 50 | + |
| 51 | + console.log(`Updating label: ${label.name}`); |
| 52 | + await github.rest.issues.updateLabel({ |
| 53 | + owner: context.repo.owner, |
| 54 | + repo: context.repo.repo, |
| 55 | + name: label.name, |
| 56 | + new_name: label.name, |
| 57 | + color: label.color, |
| 58 | + description: label.description |
| 59 | + }); |
| 60 | + } catch (error) { |
| 61 | + if (error.status === 404) { |
| 62 | + console.log(`Creating label: ${label.name}`); |
| 63 | + await github.rest.issues.createLabel({ |
| 64 | + owner: context.repo.owner, |
| 65 | + repo: context.repo.repo, |
| 66 | + name: label.name, |
| 67 | + color: label.color, |
| 68 | + description: label.description |
| 69 | + }); |
| 70 | + } else { |
| 71 | + console.error(`Error processing label ${label.name}:`, error); |
| 72 | + } |
| 73 | + } |
| 74 | + } |
0 commit comments