From 23c711d745755748f6dfc037aa87d919e28f4308 Mon Sep 17 00:00:00 2001 From: pgijsbertsen <117165507+pgijsbertsen@users.noreply.github.com> Date: Wed, 18 Feb 2026 19:44:57 +0100 Subject: [PATCH] add comment --- .../workflows/tofu-plan-k8s-wheatley.yaml | 87 +++++++++---------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml b/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml index 3d266fa..e0aabb5 100644 --- a/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml +++ b/.forgejo/workflows/tofu-plan-k8s-wheatley.yaml @@ -53,10 +53,6 @@ jobs: run: tofu plan -no-color continue-on-error: true - - name: debug - run: - echo "${{ toJSON(forge) }}" - - name: Fetch existing comments id: fetch run: | @@ -67,48 +63,43 @@ jobs: comment_id=$(echo "$response" | jq -r \ '.[] | select(.body | test("OpenTofu Format and Style")) | .id' | head -n 1) - if [ -z $comment_id ]; then - echo "Unable to fetch comment." - exit 1 + echo "$comment_id" + + - name: Upsert comment + id: comment + env: + COMMENT_BODY: | + `#### OpenTofu Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### OpenTofu Initialization ⚙️\`${{ steps.init.outcome }}\` + #### OpenTofu Validation 🤖\`${{ steps.validate.outcome }}\` +
Validation Output + + \`\`\`\n + ${{ steps.validate.outputs.stdout }} + \`\`\` + +
+ + #### OpenTofu Plan 📖\`${{ steps.plan.outcome }}\` + +
Show Plan + + \`\`\`\n + ${process.env.PLAN} + \`\`\` + +
+ run: | + if [ -n "${{ steps.fetch.outputs.comment_id }}" ] && [ "${{ steps.fetch.outputs.comment_id }}" != "null" ]; then + curl -s -X PATCH \ + -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ + -H "Content-Type: application/json" \ + "${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${{ steps.fetch.outputs.comment_id }}" \ + -d "{\"body\":\"$COMMENT_BODY\"}" + else + curl -s -X POST \ + -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ + -H "Content-Type: application/json" \ + "${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \ + -d "{\"body\":\"$COMMENT_BODY\"}" fi - - echo "comment_id=$comment_id" - - # - name: Upsert comment - # id: comment - # env: - # COMMENT_BODY: | - # `#### OpenTofu Format and Style 🖌\`${{ steps.fmt.outcome }}\` - # #### OpenTofu Initialization ⚙️\`${{ steps.init.outcome }}\` - # #### OpenTofu Validation 🤖\`${{ steps.validate.outcome }}\` - #
Validation Output - # - # \`\`\`\n - # ${{ steps.validate.outputs.stdout }} - # \`\`\` - # - #
- # - # #### OpenTofu Plan 📖\`${{ steps.plan.outcome }}\` - # - #
Show Plan - # - # \`\`\`\n - # ${process.env.PLAN} - # \`\`\` - # - #
- # run: | - # if [ -n "${{ steps.fetch.outputs.comment_id }}" ] && [ "${{ steps.fetch.outputs.comment_id }}" != "null" ]; then - # curl -s -X PATCH \ - # -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ - # -H "Content-Type: application/json" \ - # "${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${{ steps.fetch.outputs.comment_id }}" \ - # -d "{\"body\":\"$COMMENT_BODY\"}" - # else - # curl -s -X POST \ - # -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ - # -H "Content-Type: application/json" \ - # "${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \ - # -d "{\"body\":\"$COMMENT_BODY\"}" - # fi