From 4be56d0bf388ff323ccf4633b0888687ee2f3798 Mon Sep 17 00:00:00 2001 From: Viren070 Date: Tue, 17 Jun 2025 22:35:20 +0100 Subject: [PATCH] ci: try and fix discord webhook and add response logging --- .github/workflows/deploy-docker.yml | 45 ++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml index a43ee762..95afaf25 100644 --- a/.github/workflows/deploy-docker.yml +++ b/.github/workflows/deploy-docker.yml @@ -120,13 +120,20 @@ jobs: TITLE="๐ŸŒ™ Nightly Build" fi - # Format tags for display - FORMATTED_TAGS=$(for tag in $TAGS; do echo "โ€ข \`$tag\`"; done | tr '\n' '\\n') + # Format tags for display (each tag on a new line with bullet points) + FORMATTED_TAGS="" + for tag in $TAGS; do + if [ -z "$FORMATTED_TAGS" ]; then + FORMATTED_TAGS="โ€ข \`$tag\`" + else + FORMATTED_TAGS="$FORMATTED_TAGS\nโ€ข \`$tag\`" + fi + done - # Get current timestamp + # Get current timestamp in ISO 8601 format UTC TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - # Create JSON payload + # Create JSON payload file cat << EOF > discord_payload.json { "content": "$ROLE_ID", @@ -138,7 +145,7 @@ jobs: "fields": [ { "name": "๐Ÿ“ฆ Channel", - "value": "\`$CHANNEL\`", + "value": "โ€ข \`$CHANNEL\`", "inline": true }, { @@ -148,17 +155,17 @@ jobs: }, { "name": "๐Ÿ“ View Images", - "value": "[Docker Hub](https://hub.docker.com/r/viren070/aiostreams) ยท [GHCR](https://github.com/users/viren070/packages/container/aiostreams)", + "value": "[Docker Hub](https://hub.docker.com/r/viren070/aiostreams) ยท [GHCR](https://github.com/Viren070/AIOStreams/pkgs/container/aiostreams)", "inline": false }, { "name": "๐Ÿ”— View Build", - "value": "[GitHub Actions](https://github.com/Viren070/aiostreams/actions/runs/${{ github.run_id }})", + "value": "[GitHub Actions](https://github.com/Viren070/aiostreams/actions/runs/${GITHUB_RUN_ID:-0})", "inline": false } ], "footer": { - "text": "AIOStreams CI/CD", + "text": "AIOStreams CI", "icon_url": "https://github.com/Viren070.png" }, "timestamp": "$TIMESTAMP" @@ -167,8 +174,24 @@ jobs: } EOF - # Send to Discord - curl --fail --show-error -H "Content-Type: application/json" \ + echo "Sending to Discord:" + cat discord_payload.json + + # Send payload to Discord and capture response and status code + http_response=$(curl -s -w "\n%{http_code}" -H "Content-Type: application/json" \ -X POST \ -d @discord_payload.json \ - ${{ secrets.DISCORD_WEBHOOK_URL }} + "$DISCORD_WEBHOOK_URL") + + http_body=$(echo "$http_response" | sed '$d') + http_code=$(echo "$http_response" | tail -n1) + + echo "HTTP Status Code: $http_code" + echo "Discord Response Body: $http_body" + + if [ "$http_code" != "204" ]; then + echo "Error sending to Discord webhook." + exit 1 + fi + + echo "Message sent successfully!"