chore: Add tofu workflows #1
1 changed files with 26 additions and 41 deletions
|
|
@ -63,29 +63,16 @@ jobs:
|
||||||
comment_id=$(echo "$response" | jq -r \
|
comment_id=$(echo "$response" | jq -r \
|
||||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||||
|
|
||||||
echo "$comment_id"
|
echo "comment_id=$comment_id"
|
||||||
|
|
||||||
- name: Add comment
|
- name: Add comment
|
||||||
id: comment
|
id: comment
|
||||||
run: |
|
env:
|
||||||
set -euo pipefail
|
COMMENT_BODY: |
|
||||||
|
|
||||||
emoji() {
|
|
||||||
[ "$1" = success ] && echo "✅" || echo "❌"
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_OUTPUT="$(emoji ${{ steps.fmt.outcome }}) OpenTofu Format and Style"
|
|
||||||
INIT_OUTPUT="$(emoji ${{ steps.init.outcome }}) OpenTofu Initialization"
|
|
||||||
VALIDATE_OUTPUT="$(emoji ${{ steps.validate.outcome }}) OpenTofu Validation"
|
|
||||||
PLAN_OUTPUT="$(emoji ${{ steps.plan.outcome }}) OpenTofu Plan 📖"
|
|
||||||
|
|
||||||
COMMENT_BODY=$(cat <<EOF
|
|
||||||
### ${{forge.workflow}}
|
### ${{forge.workflow}}
|
||||||
|
#### OpenTofu Format and Style 🖌`${{ steps.fmt.outcome }}`
|
||||||
${FMT_OUTPUT}
|
#### OpenTofu Initialization ⚙️`${{ steps.init.outcome }}`
|
||||||
${INIT_OUTPUT}
|
#### OpenTofu Validation 🤖`${{ steps.validate.outcome }}`
|
||||||
${VALIDATE_OUTPUT}
|
|
||||||
|
|
||||||
<details><summary>Validation Output</summary>
|
<details><summary>Validation Output</summary>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -94,7 +81,7 @@ jobs:
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
${PLAN_OUTPUT}
|
#### OpenTofu Plan 📖`${{ steps.plan.outcome }}`
|
||||||
|
|
||||||
<details><summary>Show Plan</summary>
|
<details><summary>Show Plan</summary>
|
||||||
|
|
||||||
|
|
@ -103,16 +90,14 @@ jobs:
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
EOF
|
run: |
|
||||||
)
|
|
||||||
|
|
||||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||||
|
|
||||||
if [ -n "${{ steps.fetch.outputs }}" ] && [ "${{ steps.fetch.outputs }}" != "null" ]; then
|
if [ -n "${{ steps.fetch.outputs.comment_id }}" ] && [ "${{ steps.fetch.outputs.comment_id }}" != "null" ]; then
|
||||||
curl -s -X PATCH \
|
curl -s -X PATCH \
|
||||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${{ steps.fetch.outputs }}" \
|
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${{ steps.fetch.outputs.comment_id }}" \
|
||||||
-d "$payload"
|
-d "$payload"
|
||||||
else
|
else
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue