Skip to content

Commit

Permalink
Merge branch 'master' into add-snomed-mappings180624
Browse files Browse the repository at this point in the history
  • Loading branch information
twhetzel authored Jul 11, 2024
2 parents e8f2e2c + fee63fd commit 5e1ce11
Show file tree
Hide file tree
Showing 126 changed files with 1,461,005 additions and 559,210 deletions.
99 changes: 80 additions & 19 deletions .github/workflows/ontobot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ name: Create new pull request
on:
workflow_dispatch:
issues:
types: [ opened, edited ]
types: [opened, edited]
issue_comment:
types: [created, edited]

jobs:
check:
runs-on: ubuntu-latest
outputs:
phraseExists: ${{ steps.check-body.outputs.result }}
phraseExists: ${{ steps.check-body.outputs.phraseExists }}
commentId: ${{ steps.check-body.outputs.commentId }}
steps:
- name: Check if issue body contains 'Hey ontobot'
id: check-body
Expand All @@ -21,20 +24,68 @@ jobs:
repo: context.repo.repo,
issue_number: context.issue.number
});
if (!issue.data.body) {
console.log('Issue body is empty or null');
return false;
let bodyText = issue.data.body ? issue.data.body.toLowerCase() : '';
let commentId = null;
// Fetch all comments for the issue
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
// Function to check for the phrase in bodyText and comments
function checkForPhrase(bodyText, comments) {
const phrase = 'hey ontobot';
// Check if bodyText includes the phrase
let result = bodyText.includes(phrase);
// If not found in bodyText, check each comment
for (let comment of comments.reverse()) { // Reverse to give precedence to the latest comment
if (comment.body.toLowerCase().includes(phrase)) {
result = true;
commentId = comment.id;
break;
}
}
return {
result: result,
commentId: result ? commentId : null
};
}
return issue.data.body.toLowerCase().includes('hey ontobot');
const checkResult = checkForPhrase(bodyText, comments.data);
console.log(`Result: ${checkResult.result}`);
console.log(`Comment ID: ${checkResult.commentId}`);
console.log(`Check Result: ${JSON.stringify(checkResult)}`);
core.setOutput('phraseExists', checkResult.result);
core.setOutput('commentId', checkResult.commentId);
- name: Log phraseExists output
run: |
echo "phraseExists: ${{ steps.check-body.outputs.phraseExists }}"
echo "commentId: ${{ steps.check-body.outputs.commentId }}"
echo "Outputs: $(echo '${{ toJSON(steps.check-body.outputs) }}')"
- name: Conditional step based on result
if: ${{ steps.check-body.outputs.phraseExists == 'true' }}
run: echo "The phrase 'Hey ontobot' was found."


build:
needs: check
if: needs.check.outputs.phraseExists == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9"]
os: [ ubuntu-latest ]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
Expand All @@ -47,20 +98,17 @@ jobs:
id: gh-script-issue
uses: actions/github-script@v6
with:
# github-token: ${{ secrets.GH_TOKEN }}
script: |
const issue_number = context.issue.number
const repo = context.repo.owner+"/"+context.repo.repo
const issue_number = context.issue.number;
return issue_number
- name: Return repository name
id: gh-script-repo
uses: actions/github-script@v6
with:
# github-token: ${{ secrets.GH_TOKEN }}
script: |
const repo = context.repo.owner+"/"+context.repo.repo
return repo
const repo = context.repo.owner + "/" + context.repo.repo;
return repo;
- name: Set branch name
id: vars
Expand All @@ -75,15 +123,28 @@ jobs:
- name: Run ochange
id: ochange
run: |
ochange process-issue ${{ env.resource }} \
cmd="ochange process-issue ${{ env.resource }} \
-r ${{ steps.gh-script-repo.outputs.result }} \
-n ${{ steps.gh-script-issue.outputs.result }} \
-g ${{ secrets.GH_TOKEN }} \
-p MONDO
-p MONDO"
if [ "${{ needs.check.outputs.commentId }}" != "" ]; then
cmd="$cmd -c ${{ needs.check.outputs.commentId }}"
fi
echo "Running command: $cmd"
eval $cmd
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.ONTOBOT_APP_ID }}
private-key: ${{ secrets.ONTOBOT_APP_PRIVATE_KEY }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
if: ${{ env.PR_TITLE}}
if: ${{ env.PR_TITLE }}
with:
branch-suffix: short-commit-hash
labels: Automated
Expand All @@ -93,4 +154,4 @@ jobs:
title: ${{ env.PR_TITLE }}
base: ${{ github.head_ref }}
branch: ${{ env.branch-name }}
# token: ${{ secrets.GH_TOKEN }}
token: ${{ steps.app-token.outputs.token }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ src/ontology/mondo-simple.*
mondo-simple.*
mondo_edges.*
mondo_nodes.*
src/scripts/notebooks/tmp/
src/scripts/notebooks/__pycache__/sssom_pydantic.cpython-311.pyc
Loading

0 comments on commit 5e1ce11

Please sign in to comment.