Compare commits
No commits in common. "344b5344ea3534019b5ea17cebf50bdf81bd58ce" and "ad9c73c9a1e34b6fde139d5fe20c95bb6f604479" have entirely different histories.
344b5344ea
...
ad9c73c9a1
2 changed files with 6 additions and 65 deletions
|
|
@ -55,7 +55,6 @@ jobs:
|
||||||
|
|
||||||
- name: Add comment
|
- name: Add comment
|
||||||
id: comment
|
id: comment
|
||||||
if: always()
|
|
||||||
env:
|
env:
|
||||||
COMMENT_BODY: |
|
COMMENT_BODY: |
|
||||||
### ${{forge.workflow}}
|
### ${{forge.workflow}}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ name: tofu plan k8s-wheatley
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
pull_request:
|
# pull_request:
|
||||||
branches:
|
# branches:
|
||||||
- main
|
# - main
|
||||||
paths:
|
# paths:
|
||||||
- pve01.wheatley.in/templates/**
|
# - pve01.wheatley.in/templates/**
|
||||||
- .forgejo/workflows/tofu-plan-templates.yaml
|
# - .forgejo/workflows/tofu-plan-templates.yaml
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tofu-plan-k8s-wheatley:
|
tofu-plan-k8s-wheatley:
|
||||||
|
|
@ -24,18 +24,12 @@ 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
|
||||||
with:
|
with:
|
||||||
tofu_version: 1.11.5
|
tofu_version: 1.11.5
|
||||||
|
|
||||||
- name: Install deps
|
|
||||||
run: |
|
|
||||||
apt update
|
|
||||||
apt install -y jq
|
|
||||||
|
|
||||||
- name: OpenTofu Init
|
- name: OpenTofu Init
|
||||||
id: init
|
id: init
|
||||||
run: tofu init --upgrade
|
run: tofu init --upgrade
|
||||||
|
|
@ -52,55 +46,3 @@ jobs:
|
||||||
id: plan
|
id: plan
|
||||||
run: tofu plan -no-color
|
run: tofu plan -no-color
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Add comment
|
|
||||||
id: comment
|
|
||||||
if: always()
|
|
||||||
env:
|
|
||||||
COMMENT_BODY: |
|
|
||||||
### ${{forge.workflow}}
|
|
||||||
#### ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }} OpenTofu Format and Style 🖌
|
|
||||||
#### ${{ steps.init.outcome == 'success' && '✅' || '❌' }} OpenTofu Initialization ⚙️
|
|
||||||
#### ${{ steps.validate.outcome == 'success' && '✅' || '❌' }} OpenTofu Validation 🤖
|
|
||||||
<details><summary>Validation Output</summary>
|
|
||||||
|
|
||||||
```
|
|
||||||
${{ steps.validate.outputs.stdout }}
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
#### ${{ steps.plan.outcome == 'success' && '✅' || '❌' }} OpenTofu Plan 📖
|
|
||||||
|
|
||||||
<details><summary>Show Plan</summary>
|
|
||||||
|
|
||||||
```
|
|
||||||
${{ steps.plan.outputs.stdout }}
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
run: |
|
|
||||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
|
||||||
|
|
||||||
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
|
|
||||||
echo "Found comment with id ${comment_id}, updating..." && \
|
|
||||||
curl -s -X PATCH \
|
|
||||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${comment_id}" \
|
|
||||||
-d "$payload"
|
|
||||||
else
|
|
||||||
echo "Creating new comment..." && \
|
|
||||||
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 "$payload"
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue