From 7af1430289d2f3a80d8b69fce89424743e49d715 Mon Sep 17 00:00:00 2001 From: pgijsbertsen <117165507+pgijsbertsen@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:49:36 +0100 Subject: [PATCH] move comment logic --- .../workflows/tofu-plan-k8s-wheatley.yaml | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml b/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml index 4d42793..5efa9ef 100644 --- a/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml +++ b/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml @@ -53,18 +53,6 @@ jobs: run: tofu plan -no-color 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 id: comment env: @@ -93,7 +81,14 @@ jobs: run: | 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 \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ -H "Content-Type: application/json" \