REDESIGN the entire CODE OF CONDUCT page #6
This file contains 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: Auto Label Issue | |
on: | |
issues: | |
types: [opened, reopened, edited] | |
jobs: | |
label_issue: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- name: Label Issue with Custom Color | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const issue = context.payload.issue; | |
// Function to create or update a label with the specified color | |
const createOrUpdateLabel = async (label, color) => { | |
try { | |
// Check if the label already exists | |
await github.rest.issues.getLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: label | |
}); | |
// Update label color if it exists | |
await github.rest.issues.updateLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: label, | |
color: color | |
}); | |
} catch (error) { | |
// Create the label if it does not exist | |
await github.rest.issues.createLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: label, | |
color: color, | |
description: `Waiting for the Dataverse's Maintainer to review this issue.` | |
}); | |
} | |
}; | |
// Define the label name and color | |
const label = 'Review Queued'; | |
const color = 'ffae00'; // Custom color hex code | |
// Create or update the label and apply it to the issue | |
await createOrUpdateLabel(label, color); | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue.number, | |
labels: [label] | |
}); |