Architecting Growth: Scaling Tactics for Prometheus Metrics #3
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: Sync Labels from Issue to PR | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
sync-labels: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Sync Labels | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const issue_number = context.payload.pull_request.body.match(/#(\d+)/)[1]; | |
if (issue_number) { | |
const issue = await github.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
}); | |
const labels = issue.data.labels.map(label => label.name); | |
await github.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: labels | |
}); | |
} |