From 2c27f45bacca5162ccbb08a9d690ee68fd9aac88 Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Wed, 14 Feb 2024 23:12:45 -0600 Subject: [PATCH 1/2] Add ontobot workflow --- .github/workflows/onotobot.yml | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/onotobot.yml diff --git a/.github/workflows/onotobot.yml b/.github/workflows/onotobot.yml new file mode 100644 index 0000000..451e6d5 --- /dev/null +++ b/.github/workflows/onotobot.yml @@ -0,0 +1,94 @@ +name: Create new pull request + +on: + workflow_dispatch: + issues: + types: [ opened, edited ] + +jobs: + check: + runs-on: ubuntu-latest + outputs: + phraseExists: ${{ steps.check-body.outputs.result }} + steps: + - name: Check if issue body contains 'Hey ontobot' + id: check-body + uses: actions/github-script@v6 + with: + script: | + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + if (!issue.data.body) { + console.log('Issue body is empty or null'); + return false; + } + return issue.data.body.toLowerCase().includes('hey ontobot'); + + build: + needs: check + if: needs.check.outputs.phraseExists == 'true' + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.9"] + os: [ ubuntu-latest ] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Return issue number + 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 + 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 + + - name: Set branch name + id: vars + run: | + echo "resource=src/ontology/pato-edit.obo" >> $GITHUB_ENV + echo "branch-name=ochange_automation_"${{ steps.gh-script-issue.outputs.result }} >> $GITHUB_ENV + + - name: Install dependencies + run: | + pip install ontobot-change-agent + + - name: Run ochange + id: ochange + run: | + ochange process-issue ${{ env.resource }} \ + -r ${{ steps.gh-script-repo.outputs.result }} \ + -n ${{ steps.gh-script-issue.outputs.result }} \ + -g ${{ secrets.GH_TOKEN }} + -p PATO + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + if: ${{ env.PR_TITLE}} + with: + branch-suffix: short-commit-hash + labels: Automated + body: ${{ env.PR_BODY }} + title: ${{ env.PR_TITLE }} + base: ${{ github.head_ref }} + branch: ${{ env.branch-name }} + # token: ${{ secrets.GH_TOKEN }} \ No newline at end of file From 0b364c7ee7f0f65b291fce10509177fd6f72b525 Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Wed, 14 Feb 2024 23:20:50 -0600 Subject: [PATCH 2/2] typo --- .github/workflows/onotobot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/onotobot.yml b/.github/workflows/onotobot.yml index 451e6d5..ecac121 100644 --- a/.github/workflows/onotobot.yml +++ b/.github/workflows/onotobot.yml @@ -78,7 +78,7 @@ jobs: ochange process-issue ${{ env.resource }} \ -r ${{ steps.gh-script-repo.outputs.result }} \ -n ${{ steps.gh-script-issue.outputs.result }} \ - -g ${{ secrets.GH_TOKEN }} + -g ${{ secrets.GH_TOKEN }} \ -p PATO - name: Create Pull Request