chore: Add tofu workflows #1
1 changed files with 35 additions and 7 deletions
|
|
@ -56,18 +56,46 @@ jobs:
|
|||
- name: Fetch existing comments
|
||||
id: fetch
|
||||
run: |
|
||||
response=$(curl -s \
|
||||
set -euxo pipefail
|
||||
|
||||
echo "PR_NUMBER: $PR_NUMBER"
|
||||
echo "Forgejo URL: ${{ forge.server_url }}"
|
||||
echo "Repo: ${{ forge.repository }}"
|
||||
|
||||
url="${{ forge.server_url }}/api/v1/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments"
|
||||
|
||||
echo "Requesting: $url"
|
||||
|
||||
response=$(curl -sS -w "\nHTTP_STATUS:%{http_code}\n" \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ forge.server_url }}/api/v1/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||
"$url")
|
||||
|
||||
comment_id=$(echo "$response" | jq -r \
|
||||
'.[] | select(.body | test("OpenTofu Format and Style")) | .id' | head -n 1)
|
||||
http_status=$(echo "$response" | sed -n 's/HTTP_STATUS://p')
|
||||
body=$(echo "$response" | sed '/HTTP_STATUS:/d')
|
||||
|
||||
if [ -z $comment_id ]; then
|
||||
exit 1
|
||||
echo "HTTP status: $http_status"
|
||||
|
||||
if [ "$http_status" != "200" ]; then
|
||||
echo "Forgejo API call failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "comment_id=$comment_id"
|
||||
echo "Parsing JSON…"
|
||||
|
||||
echo "$body" | jq .
|
||||
|
||||
comment_id=$(echo "$body" | jq -r \
|
||||
'.[] | select(.body | test("OpenTofu Format and Style")) | .id' | head -n 1)
|
||||
|
||||
echo "Matched comment_id: '$comment_id'"
|
||||
|
||||
if [ -z "$comment_id" ] || [ "$comment_id" = "null" ]; then
|
||||
echo "No existing comment found matching marker"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found comment id: $comment_id"
|
||||
echo "comment_id=$comment_id" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upsert comment
|
||||
id: comment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue