fixed main build notification
This commit is contained in:
1 parent
8205fee420
commit
802544e452
1 file changed
+84
-8
@@ -53,7 +53,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
JOB_STATUS: ${{ job.status }}
|
JOB_STATUS: ${{ job.status }}
|
||||||
DEPLOY_ENVIRONMENT: dev
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
||||||
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
||||||
@@ -61,14 +60,53 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$JOB_STATUS" = "success" ]; then
|
if [ "$JOB_STATUS" = "success" ]; then
|
||||||
STATUS_LABEL="SUCCESS"
|
STATUS_TITLE="Deploy succeeded"
|
||||||
|
COLOR=65280
|
||||||
else
|
else
|
||||||
STATUS_LABEL="FAILED"
|
STATUS_TITLE="Deploy failed"
|
||||||
|
COLOR=16711680
|
||||||
fi
|
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 \
|
curl --fail --show-error --silent \
|
||||||
-H "Content-Type: application/json" \
|
-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."
|
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."
|
||||||
|
|
||||||
deploy-prod:
|
deploy-prod:
|
||||||
@@ -121,7 +159,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
JOB_STATUS: ${{ job.status }}
|
JOB_STATUS: ${{ job.status }}
|
||||||
DEPLOY_ENVIRONMENT: production
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
||||||
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
||||||
@@ -129,12 +166,51 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$JOB_STATUS" = "success" ]; then
|
if [ "$JOB_STATUS" = "success" ]; then
|
||||||
STATUS_LABEL="SUCCESS"
|
STATUS_TITLE="Deploy succeeded"
|
||||||
|
COLOR=65280
|
||||||
else
|
else
|
||||||
STATUS_LABEL="FAILED"
|
STATUS_TITLE="Deploy failed"
|
||||||
|
COLOR=16711680
|
||||||
fi
|
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 \
|
curl --fail --show-error --silent \
|
||||||
-H "Content-Type: application/json" \
|
-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."
|
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."
|
||||||
Reference in new issue
Block a user