fixed main build notification
Deploy / deploy-dev (push) Skipped
Deploy / deploy-prod (push) Successful in 1m57s

This commit is contained in:
blaisadmin committed 2026-10-07 19:49:17 -04:00
1 parent 8205fee420
commit 802544e452
1 file changed
+84 -8
+84 -8
View File
@@ -53,7 +53,6 @@ jobs:
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
JOB_STATUS: ${{ job.status }}
DEPLOY_ENVIRONMENT: dev
run: |
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
@@ -61,14 +60,53 @@ jobs:
fi
if [ "$JOB_STATUS" = "success" ]; then
STATUS_LABEL="SUCCESS"
STATUS_TITLE="Deploy succeeded"
COLOR=65280
else
STATUS_LABEL="FAILED"
STATUS_TITLE="Deploy failed"
COLOR=16711680
fi
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
AVATAR_URL="${{ vars.DISCORD_AVATAR_URL }}"
AVATAR_URL="${AVATAR_URL:-https://www.flockpal.app/FlockPal-Paint.png}"
COMMIT_MESSAGE="$(git -C /docker/FlockPal-dev log -1 --pretty=%s 2>/dev/null || printf '%s' '${{ github.sha }}')"
json_escape() {
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
}
BRANCH="$(json_escape '${{ github.ref_name }}')"
MESSAGE="$(json_escape "$COMMIT_MESSAGE")"
AVATAR_URL="$(json_escape "$AVATAR_URL")"
cat > /tmp/discord-payload.json <<EOF
{
"username": "FlockPal Build",
"avatar_url": "${AVATAR_URL}",
"embeds": [
{
"title": "${STATUS_TITLE}",
"url": "${RUN_URL}",
"description": "FlockPal dev deploy",
"color": ${COLOR},
"fields": [
{
"name": "Branch",
"value": "${BRANCH}",
"inline": true
},
{
"name": "Message",
"value": "${MESSAGE}",
"inline": false
}
]
}
]
}
EOF
curl --fail --show-error --silent \
-H "Content-Type: application/json" \
-d "{\"content\":\"[${STATUS_LABEL}] FlockPal ${DEPLOY_ENVIRONMENT} deploy completed with status: ${JOB_STATUS}\\nBranch: ${{ github.ref_name }}\\nCommit: ${{ github.sha }}\\nRun: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
-d @/tmp/discord-payload.json \
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."
deploy-prod:
@@ -121,7 +159,6 @@ jobs:
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
JOB_STATUS: ${{ job.status }}
DEPLOY_ENVIRONMENT: production
run: |
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
@@ -129,12 +166,51 @@ jobs:
fi
if [ "$JOB_STATUS" = "success" ]; then
STATUS_LABEL="SUCCESS"
STATUS_TITLE="Deploy succeeded"
COLOR=65280
else
STATUS_LABEL="FAILED"
STATUS_TITLE="Deploy failed"
COLOR=16711680
fi
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
AVATAR_URL="${{ vars.DISCORD_AVATAR_URL }}"
AVATAR_URL="${AVATAR_URL:-https://www.flockpal.app/FlockPal-Paint.png}"
COMMIT_MESSAGE="$(git -C /docker/FlockPal log -1 --pretty=%s 2>/dev/null || printf '%s' '${{ github.sha }}')"
json_escape() {
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
}
BRANCH="$(json_escape '${{ github.ref_name }}')"
MESSAGE="$(json_escape "$COMMIT_MESSAGE")"
AVATAR_URL="$(json_escape "$AVATAR_URL")"
cat > /tmp/discord-payload.json <<EOF
{
"username": "FlockPal Build",
"avatar_url": "${AVATAR_URL}",
"embeds": [
{
"title": "${STATUS_TITLE}",
"url": "${RUN_URL}",
"description": "FlockPal production deploy",
"color": ${COLOR},
"fields": [
{
"name": "Branch",
"value": "${BRANCH}",
"inline": true
},
{
"name": "Message",
"value": "${MESSAGE}",
"inline": false
}
]
}
]
}
EOF
curl --fail --show-error --silent \
-H "Content-Type: application/json" \
-d "{\"content\":\"[${STATUS_LABEL}] FlockPal ${DEPLOY_ENVIRONMENT} deploy completed with status: ${JOB_STATUS}\\nBranch: ${{ github.ref_name }}\\nCommit: ${{ github.sha }}\\nRun: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
-d @/tmp/discord-payload.json \
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."