Skip to content

Commit ce15ae0

Browse files
authored
chore(ci): announce releases on Discord (#26897)
1 parent 359d4fd commit ce15ae0

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Announce Releases on Discord
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
description: "Published release tag"
8+
type: string
9+
required: true
10+
secrets:
11+
DISCORD_ANNOUNCEMENTS_WEBHOOK_URL:
12+
required: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
announce:
19+
# Disable the native GitHub release webhook before enabling this repository variable.
20+
if: github.repository == 'vectordotdev/vector' && vars.DISCORD_RELEASES_ENABLED == 'true'
21+
runs-on: ubuntu-24.04
22+
timeout-minutes: 5
23+
continue-on-error: true
24+
steps:
25+
- name: Read published release
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
RELEASE_TAG: ${{ inputs.tag }}
29+
run: |
30+
encoded_tag=$(jq -rn --arg tag "$RELEASE_TAG" '$tag | @uri')
31+
gh api "repos/$GITHUB_REPOSITORY/releases/tags/$encoded_tag" > "$RUNNER_TEMP/release.json"
32+
jq -e --arg tag "$RELEASE_TAG" '
33+
.tag_name == $tag and .draft == false and .published_at != null
34+
' "$RUNNER_TEMP/release.json" > /dev/null
35+
36+
- name: Post release to Discord
37+
env:
38+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_ANNOUNCEMENTS_WEBHOOK_URL }}
39+
run: |
40+
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
41+
echo "::error::DISCORD_ANNOUNCEMENTS_WEBHOOK_URL is not configured"
42+
exit 1
43+
fi
44+
45+
# Bound the payload size even when every character uses four UTF-8 bytes.
46+
jq '{
47+
username: "Vector Releases",
48+
allowed_mentions: {parse: []},
49+
embeds: [{
50+
title: (("Vector " + .tag_name)[:128]),
51+
url: .html_url,
52+
description: ((.body // "") |
53+
if length > 1000 then .[:1000] + "…" else . end),
54+
footer: {text: (if .prerelease or (.tag_name | split("+")[0] | contains("-")) then "Pre-release" else "Release" end)}
55+
}]
56+
}' "$RUNNER_TEMP/release.json" > "$RUNNER_TEMP/discord-release.json"
57+
58+
curl --fail --silent --show-error \
59+
--connect-timeout 10 --max-time 30 \
60+
--header 'Content-Type: application/json' \
61+
--data-binary "@$RUNNER_TEMP/discord-release.json" \
62+
--output /dev/null \
63+
"${DISCORD_WEBHOOK_URL}?wait=true"
64+
65+
- name: Report notification failure
66+
if: failure()
67+
run: echo "::warning::Discord release notification failed; release publishing can continue."

‎.github/workflows/publish.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,18 @@ jobs:
578578
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
579579
run: make release-github
580580

581+
announce-discord:
582+
name: Announce release on Discord
583+
needs: [generate-publish-metadata, publish-github]
584+
if: ${{ !inputs.skip_publish && inputs.channel == 'release' }}
585+
permissions:
586+
contents: read
587+
uses: ./.github/workflows/discord-releases.yml
588+
with:
589+
tag: v${{ needs.generate-publish-metadata.outputs.vector_version }}
590+
secrets:
591+
DISCORD_ANNOUNCEMENTS_WEBHOOK_URL: ${{ secrets.DISCORD_ANNOUNCEMENTS_WEBHOOK_URL }}
592+
581593
generate-sha256sum:
582594
name: Generate SHA256 checksums
583595
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)