From aa041c5e622ab449b63808c38bb6b556149d8d39 Mon Sep 17 00:00:00 2001 From: "Trez.One" Date: Sun, 19 Oct 2025 11:07:31 -0400 Subject: [PATCH] PR number extraction and custom PR comment action. --- .gitea/workflows/auto-pr-tofu-plan.yml | 54 +++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/auto-pr-tofu-plan.yml b/.gitea/workflows/auto-pr-tofu-plan.yml index fedbe2d..7632ff4 100644 --- a/.gitea/workflows/auto-pr-tofu-plan.yml +++ b/.gitea/workflows/auto-pr-tofu-plan.yml @@ -9,6 +9,7 @@ on: env: OPENTOFU_VERSION: "1.10.6" HC_VAULT_VERSION: "1.20.4" + TEA_VERSION: "0.10.1" jobs: check-and-create-pr: @@ -64,6 +65,35 @@ jobs: version: ${{ env.OPENTOFU_VERSION }} tofu_wrapper: true + - name: Install Tea + id: install-tea-pr-index + env: + TEA_DL_URL: "https://dl.gitea.com/tea/${{ env.TEA_VERSION }}/tea-${{ env.TEA_VERSION }}-linux-amd64" + shell: bash + run: | + echo ${{ gitea.ref_name }} + + cd /tmp + wget -q "${TEA_DL_URL}" + wget -q "${TEA_DL_URL}.sha256" + if $(sha256sum --quiet -c "tea-${{ inputs.tea-version }}-linux-amd64.sha256"); then + mv "tea-${{ inputs.tea-version }}-linux-amd64" /usr/bin/tea + chmod +x /usr/bin/tea + else + echo "WARNING ⛔: Tea v${{ inputs.tea-version }} Checksum Failed" + exit 1 + fi + + pr_number=$(tea pr ls --repo ${{ gitea.repository }} \ + --state open \ + --fields index,state,head \ + --output simple \ + | awk '{print $1}') + + echo ${pr_number} + + echo "pr_number=$pr_number" >> $GITHUB_OUTPUT + - name: Generate .env from Hashicorp Vault uses: https://git.trez.wtf/Trez/hc-vault-env@main with: @@ -107,6 +137,7 @@ jobs: - name: Tofu Plan id: tofu_plan + continue-on-error: true uses: dnogu/tofu-plan@v1 with: working-directory: . @@ -136,10 +167,21 @@ jobs: # show-sensitive: # display-plan: - - name: Tofu Plan Comment - id: tofu_plan - uses: alexnorell/tofu-pr-commenter@v2.0.0 + - name: PR Comment + uses: https://git.trez.wtf/Trez.One/git-auto-comment@main with: - commenter_type: plan - commenter_input: ${{ steps.tofu_plan.outputs.plan-output }} - commenter_exitcode: ${{ steps.tofu_plan.outputs.exitcode }} \ No newline at end of file + platform: gitea + token: ${BOT_GITEA_TOKEN} + pr_index: $${{ steps.install-tea-pr-index.outputs.pr_number }} + comment_template: | + ${{ steps.tofu_plan.outputs.plan-output }} + ____________________________________ + ${{ steps.tofu_plan.outputs.exitcode }} + + # - name: Tofu Plan Comment + # id: tofu_plan + # uses: alexnorell/tofu-pr-commenter@v2.0.0 + # with: + # commenter_type: plan + # commenter_input: ${{ steps.tofu_plan.outputs.plan-output }} + # commenter_exitcode: ${{ steps.tofu_plan.outputs.exitcode }} \ No newline at end of file