Add Discord deploy notifications
This commit is contained in:
@@ -47,6 +47,67 @@ jobs:
|
||||
cd /docker/FlockPal-dev
|
||||
docker compose -f docker-compose.dev.yaml up -d --build
|
||||
|
||||
- name: Notify Discord
|
||||
if: always()
|
||||
env:
|
||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
JOB_STATUS: ${{ job.status }}
|
||||
run: |
|
||||
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
||||
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$JOB_STATUS" = "success" ]; then
|
||||
STATUS_TITLE="Deploy succeeded"
|
||||
COLOR=65280
|
||||
else
|
||||
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://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 @/tmp/discord-payload.json \
|
||||
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."
|
||||
|
||||
deploy-prod:
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
runs-on: ubuntu-latest
|
||||
@@ -85,3 +146,64 @@ jobs:
|
||||
set -e
|
||||
cd /docker/FlockPal
|
||||
docker compose -f docker-compose.prod.yml up -d --build
|
||||
|
||||
- name: Notify Discord
|
||||
if: always()
|
||||
env:
|
||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
JOB_STATUS: ${{ job.status }}
|
||||
run: |
|
||||
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
|
||||
echo "DISCORD_WEBHOOK_URL is not configured; skipping Discord notification."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$JOB_STATUS" = "success" ]; then
|
||||
STATUS_TITLE="Deploy succeeded"
|
||||
COLOR=65280
|
||||
else
|
||||
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://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 @/tmp/discord-payload.json \
|
||||
"$DISCORD_WEBHOOK_URL" || echo "Discord notification failed."
|
||||
|
||||
@@ -95,6 +95,8 @@ curl -H "Authorization: Bearer <admin-token>" https://your-host/api/metrics
|
||||
- `S3_ACCESS_KEY_ID`
|
||||
- `S3_SECRET_ACCESS_KEY`
|
||||
- `RESCUE_ONBOARDING_WEBHOOK_URL`
|
||||
- `DISCORD_WEBHOOK_URL` as a Gitea Actions secret for deploy notifications
|
||||
- `DISCORD_AVATAR_URL` as an optional Gitea Actions variable for the deploy notification icon
|
||||
2. Build and start the production stack:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user