From 90cc6db8b5b5f9ed77add5181941fd8f27c22fb0 Mon Sep 17 00:00:00 2001 From: sanggusti Date: Tue, 22 Aug 2023 19:00:47 +0200 Subject: [PATCH] Feat: add bot flagging for /bug comment --- .github/workflows/exercise-ghapi.yaml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/exercise-ghapi.yaml diff --git a/.github/workflows/exercise-ghapi.yaml b/.github/workflows/exercise-ghapi.yaml new file mode 100644 index 0000000..f86f9af --- /dev/null +++ b/.github/workflows/exercise-ghapi.yaml @@ -0,0 +1,33 @@ +name : exercise-ghapi +on: issue_comment + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + ghapi-exercise: + if: (github.event.issue.pull_request != null) && contains(github.event.comment.body, '/bug') + runs-on: ubuntu-latest + steps: + - name: install dependencies + run: pip install ghapi + + - name: see payload + run: echo "PAYLOAD:\n${PAYLOAD}\n" + env: + PAYLOAD: ${{ toJson(github.event) }} + + - name: Make a comment + shell: python + run: | + import os + from ghapi.core import GhApi + owner,repo = os.environ['REPO'].split('/') + api = GhApi(owner=owner, repo=repo) + api.issues.add_labels(issue_number=os.environ['NUMBER'], labels=['bug']) + env: + NUMBER: ${{ github.event.issue.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} \ No newline at end of file