From 949a81509887e8b766f9a7066be9852c5ef7a4b1 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Tue, 12 Dec 2023 12:22:38 -0700 Subject: [PATCH] [Chore] Update actions to work together --- .github/workflows/automated-review.yml | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/automated-review.yml diff --git a/.github/workflows/automated-review.yml b/.github/workflows/automated-review.yml new file mode 100644 index 00000000000000..4ea38d6226d46a --- /dev/null +++ b/.github/workflows/automated-review.yml @@ -0,0 +1,44 @@ +name: Automated review + +# **What it does**: Adds a comment to highlight potential issues and fixes. +# **Why we have it**: Makes contributing and reviewing easier. +# **Who does it impact**: All contributors. + +on: + pull_request: + branches: + - production + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + review: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Check for existing comment + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + existing_comment_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \ + jq '.[] | select(.user.id == 41898282) | select(.body | contains("TEST")) | .id') + + comment_body="TEST" + # If a comment exists, update it. Otherwise, post a new comment. + if [ ! -z "$existing_comment_id" ]; then + curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + -X PATCH -d "$comment_body" \ + "https://api.github.com/repos/${{ github.repository }}/issues/comments/$existing_comment_id" + else + curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + -X POST -d "$comment_body" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" + fi \ No newline at end of file