chore: Add tofu workflows #1

Merged
Peter merged 82 commits from pgi-add-workflows into main 2026-02-18 22:55:53 +01:00
Showing only changes of commit 6683e0febc - Show all commits

View file

@ -24,6 +24,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }} TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }} TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
PR_NUMBER: ${{ forge.event.pull_request.number }}
steps: steps:
- uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/checkout@v4
- uses: https://github.com/opentofu/setup-opentofu@v1 - uses: https://github.com/opentofu/setup-opentofu@v1
@ -46,3 +47,57 @@ jobs:
id: plan id: plan
run: tofu plan -no-color run: tofu plan -no-color
continue-on-error: true continue-on-error: true
- name: Fetch existing comments
id: fetch
run: |
response=$(curl -s \
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
"${{ forge.server_url }}/api/v1/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
comment_id=$(echo "$response" | jq -r \
'.[] | select(.body | test("OpenTofu Format and Style")) | .id' | head -n 1)
echo "::set-output name=comment_id::$comment_id"
- name: Set variables
run: |
echo "COMMENT_ID=${{ steps.fetch.outputs.comment_id }}" >> $FORGEJO_ENV
- name: Upsert comment
env:
COMMENT_BODY: |
`#### OpenTofu Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### OpenTofu Initialization ⚙️\`${{ steps.init.outcome }}\`
#### OpenTofu Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
#### OpenTofu Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
run: |
if [ -n "$COMMENT_ID" ] && [ "$COMMENT_ID" != "null" ]; then
curl -s -X PATCH \
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
-H "Content-Type: application/json" \
"$FORGEJO_URL/api/v1/repos/${{ forge.repository }}/issues/comments/$COMMENT_ID" \
-d "{\"body\":\"$COMMENT_BODY\"}"
else
curl -s -X POST \
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
-H "Content-Type: application/json" \
"$FORGEJO_URL/api/v1/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \
-d "{\"body\":\"$COMMENT_BODY\"}"
fi