mirror of https://github.com/jumpserver/jumpserver
Bai
3 weeks ago
committed by
Bryan
1 changed files with 14 additions and 18 deletions
@ -1,28 +1,24 @@ |
|||||||
name: Post Release to Discord |
name: Publish Release to Discord |
||||||
|
|
||||||
on: |
on: |
||||||
release: |
release: |
||||||
types: [published] |
types: [published] |
||||||
|
|
||||||
jobs: |
jobs: |
||||||
post-release-to-discord: |
send_discord_notification: |
||||||
runs-on: ubuntu-latest |
runs-on: ubuntu-latest |
||||||
|
if: startsWith(github.event.release.tag_name, 'v4.') |
||||||
steps: |
steps: |
||||||
- name: Check if release tag starts with v4 |
- name: Send release notification to Discord |
||||||
id: check_tag |
env: |
||||||
|
WEBHOOK_URL: ${{ secrets.DISCORD_CHANGELOG_WEBHOOK }} |
||||||
run: | |
run: | |
||||||
if [[ "${{ github.event.release.tag_name }}" == v4* ]]; then |
# 获取标签名称和 release body |
||||||
echo "Tag starts with v4" |
TAG_NAME="${{ github.event.release.tag_name }}" |
||||||
echo "::set-output name=send_message::true" |
RELEASE_BODY="${{ github.event.release.body }}" |
||||||
else |
|
||||||
echo "Tag does not start with v4" |
|
||||||
echo "::set-output name=send_message::false" |
|
||||||
fi |
|
||||||
|
|
||||||
- name: Post release to Discord |
# 使用 jq 构建 JSON 数据,以确保安全传递 |
||||||
if: steps.check_tag.outputs.send_message == 'true' |
JSON_PAYLOAD=$(jq -n --arg tag "# JumpServer $TAG_NAME Released! 🚀" --arg body "$RELEASE_BODY" '{content: "\($tag)\n\($body)"}') |
||||||
run: | |
|
||||||
curl -H "Content-Type: application/json" -d \ |
# 使用 curl 发送 JSON 数据 |
||||||
"{\"content\": \"JumpServer ${{ github.event.release.tag_name }} Released! 🚀\\n${{ github.event.release.body }}\"}" \ |
curl -X POST -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$WEBHOOK_URL" |
||||||
$DISCORD_CHANGELOG_WEBHOOK |
|
Loading…
Reference in new issue