move comment logic
All checks were successful
Tofu Plan k8s-wheatley / tofu-plan-k8s-wheatley (pull_request) Successful in 23s
All checks were successful
Tofu Plan k8s-wheatley / tofu-plan-k8s-wheatley (pull_request) Successful in 23s
This commit is contained in:
parent
90c7c56e65
commit
7af1430289
1 changed files with 8 additions and 13 deletions
|
|
@ -53,18 +53,6 @@ jobs:
|
||||||
run: tofu plan -no-color
|
run: tofu plan -no-color
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Fetch existing comment ID
|
|
||||||
id: fetch
|
|
||||||
run: |
|
|
||||||
response=$(curl -s \
|
|
||||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
|
||||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
|
||||||
|
|
||||||
comment_id=$(echo "$response" | jq -r \
|
|
||||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
|
||||||
|
|
||||||
echo "$comment_id"
|
|
||||||
|
|
||||||
- name: Add comment
|
- name: Add comment
|
||||||
id: comment
|
id: comment
|
||||||
env:
|
env:
|
||||||
|
|
@ -93,7 +81,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||||
|
|
||||||
if [ -n "${{ steps.fetch.outputs }}" ] && [ "${{ steps.fetch.outputs }}" != "null" ]; then
|
existing_comment=$(curl -s \
|
||||||
|
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||||
|
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||||
|
comment_id=$(echo "$existing_comment" | jq -r \
|
||||||
|
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "${comment_id}" ] && [ "${comment_id}" != "null" ]; then
|
||||||
curl -s -X PATCH \
|
curl -s -X PATCH \
|
||||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue