Added a GitHub action... #12
Workflow file for this run
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: Label Predicate Changes | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
issues: | |
types: [opened, edited, labeled] | |
jobs: | |
label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Label PR if predicates changed | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const keywords = ['predicate', 'biolink:']; | |
const labelName = 'Biological Context QC'; | |
// Check if the event is for an issue | |
let item, number; | |
if (context.event.issue) { | |
// It's an issue | |
item = context.event.issue; | |
number = item.number; | |
} else { | |
// It's a pull request | |
item = context.payload.pull_request; | |
number = item.number; | |
} | |
// Check if the title or body contains any keywords | |
const containsKeyword = (text) => { | |
return keywords.some(keyword => text.toLowerCase().includes(keyword.toLowerCase())); | |
}; | |
if (containsKeyword(item.title) || containsKeyword(item.body)) { | |
// Add label if keywords found | |
await github.issues.addLabels({ | |
...context.repo, | |
issue_number: number, | |
labels: [labelName] | |
}); | |
} | |
- name: Assign Issue if Labeled | |
uses: actions/github-script@v6 | |
if: github.event.action == 'labeled' && github.event.label.name == 'Biological Context QC' | |
with: | |
script: | | |
const assignee = 'eKathleenCarter'; // Change this to the desired assignee's GitHub username | |
// Assign the issue | |
await github.issues.addAssignees({ | |
...context.repo, | |
issue_number: context.issue.number, | |
assignees: [assignee] | |
}); |