test issue labels action #7
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: Add repo name to issue label | |
on: | |
issues: | |
pull_request: | |
jobs: | |
add-label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: add label | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} | |
script: | | |
try { | |
const response = await github.rest.issues.createLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: context.repo.repo, | |
color: 'B60205', | |
description: 'RepoName' | |
}); | |
console.log('LABEL ' + context.repo.repo + ' CREATED SUCCESSFULLY'); | |
} catch (createLabelError) { | |
console.log('FAILED TO CREATE LABEL ' + context.repo.repo + ' ... MAY BE IT ALREADY EXISTS.'); | |
console.log('FAILURE MSG: ' + createLabelError.message); | |
} | |
github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [context.repo.repo] | |
}) |