Skip to content

Commit

Permalink
[Chore] Update actions to work together
Browse files Browse the repository at this point in the history
  • Loading branch information
kodster28 committed Dec 12, 2023
1 parent 0b18b8d commit 949a815
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/automated-review.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 949a815

Please sign in to comment.