-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from RobokopU24/add_GHaction
Added a GitHub action...
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import requests | ||
|
||
PREDICATE_KEYWORDS = ["predicate", "biolink:", "edges"] | ||
LABEL_NAME = "Biological Context QC" # Label to add if keywords are found | ||
|
||
# GitHub API variables | ||
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") | ||
REPO_NAME = os.getenv("GITHUB_REPOSITORY") | ||
ISSUE_NUMBER = os.getenv("ISSUE_NUMBER") | ||
print("GITHUB_TOKEN:", GITHUB_TOKEN) | ||
print("REPO_NAME:", REPO_NAME) | ||
print("ISSUE_NUMBER:", ISSUE_NUMBER) | ||
|
||
headers = {"Authorization": f"Bearer {GITHUB_TOKEN}"} | ||
api_url = f"https://api.github.com/repos/{REPO_NAME}" | ||
|
||
def get_issue_details(issue_number): | ||
response = requests.get(f"{api_url}/issues/{issue_number}", headers=headers) | ||
response.raise_for_status() | ||
return response.json() | ||
|
||
def add_label(issue_number, label_name): | ||
response = requests.post( | ||
f"{api_url}/issues/{issue_number}/labels", | ||
headers=headers, | ||
json={"labels": [label_name]} | ||
) | ||
response.raise_for_status() | ||
print(f"Label '{label_name}' added to issue/PR #{issue_number}") | ||
|
||
def check_keywords_in_text(text, keywords): | ||
return any(keyword in text for keyword in keywords) | ||
|
||
def main(): | ||
issue_details = get_issue_details(ISSUE_NUMBER) | ||
title = issue_details["title"] | ||
body = issue_details["body"] | ||
|
||
if check_keywords_in_text(title, PREDICATE_KEYWORDS) or check_keywords_in_text(body, PREDICATE_KEYWORDS): | ||
add_label(ISSUE_NUMBER, LABEL_NAME) | ||
else: | ||
print("No predicate keywords found.") | ||
|
||
if __name__ == "__main__": | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: 'Label Predicate Changes' | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
label_check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
pip install PyGithub | ||
- name: Run predicate check | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} | ||
run: | | ||
python .github/scripts/Bio_QC_check.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ neo4j==5.20.0 | |
pyoxigraph==0.3.22 | ||
curies==0.7.9 | ||
prefixmaps==0.2.4 | ||
bmt==1.4.1 | ||
bmt==1.4.1 |