chore: Add tofu workflows #1
1 changed files with 55 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ jobs:
|
|||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
|
||||
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
|
||||
PR_NUMBER: ${{ forge.event.pull_request.number }}
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/opentofu/setup-opentofu@v1
|
||||
|
|
@ -46,3 +47,57 @@ jobs:
|
|||
id: plan
|
||||
run: tofu plan -no-color
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue