Skip to content

Commit 2a0b138

Browse files
authored
build: add gh action to process releases (comfyanonymous#8652)
1 parent e195c1b commit 2a0b138

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/release-webhook.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release Webhook
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
send-webhook:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Send release webhook
12+
env:
13+
WEBHOOK_URL: ${{ secrets.RELEASE_GITHUB_WEBHOOK_URL }}
14+
WEBHOOK_SECRET: ${{ secrets.RELEASE_GITHUB_WEBHOOK_SECRET }}
15+
run: |
16+
# Generate UUID for delivery ID
17+
DELIVERY_ID=$(uuidgen)
18+
HOOK_ID="release-webhook-$(date +%s)"
19+
20+
# Create webhook payload matching GitHub release webhook format
21+
PAYLOAD=$(cat <<EOF
22+
{
23+
"action": "published",
24+
"release": {
25+
"id": ${{ github.event.release.id }},
26+
"node_id": "${{ github.event.release.node_id }}",
27+
"url": "${{ github.event.release.url }}",
28+
"html_url": "${{ github.event.release.html_url }}",
29+
"assets_url": "${{ github.event.release.assets_url }}",
30+
"upload_url": "${{ github.event.release.upload_url }}",
31+
"tag_name": "${{ github.event.release.tag_name }}",
32+
"target_commitish": "${{ github.event.release.target_commitish }}",
33+
"name": ${{ toJSON(github.event.release.name) }},
34+
"body": ${{ toJSON(github.event.release.body) }},
35+
"draft": ${{ github.event.release.draft }},
36+
"prerelease": ${{ github.event.release.prerelease }},
37+
"created_at": "${{ github.event.release.created_at }}",
38+
"published_at": "${{ github.event.release.published_at }}",
39+
"author": {
40+
"login": "${{ github.event.release.author.login }}",
41+
"id": ${{ github.event.release.author.id }},
42+
"node_id": "${{ github.event.release.author.node_id }}",
43+
"avatar_url": "${{ github.event.release.author.avatar_url }}",
44+
"url": "${{ github.event.release.author.url }}",
45+
"html_url": "${{ github.event.release.author.html_url }}",
46+
"type": "${{ github.event.release.author.type }}",
47+
"site_admin": ${{ github.event.release.author.site_admin }}
48+
},
49+
"tarball_url": "${{ github.event.release.tarball_url }}",
50+
"zipball_url": "${{ github.event.release.zipball_url }}",
51+
"assets": ${{ toJSON(github.event.release.assets) }}
52+
},
53+
"repository": {
54+
"id": ${{ github.event.repository.id }},
55+
"node_id": "${{ github.event.repository.node_id }}",
56+
"name": "${{ github.event.repository.name }}",
57+
"full_name": "${{ github.event.repository.full_name }}",
58+
"private": ${{ github.event.repository.private }},
59+
"owner": {
60+
"login": "${{ github.event.repository.owner.login }}",
61+
"id": ${{ github.event.repository.owner.id }},
62+
"node_id": "${{ github.event.repository.owner.node_id }}",
63+
"avatar_url": "${{ github.event.repository.owner.avatar_url }}",
64+
"url": "${{ github.event.repository.owner.url }}",
65+
"html_url": "${{ github.event.repository.owner.html_url }}",
66+
"type": "${{ github.event.repository.owner.type }}",
67+
"site_admin": ${{ github.event.repository.owner.site_admin }}
68+
},
69+
"html_url": "${{ github.event.repository.html_url }}",
70+
"clone_url": "${{ github.event.repository.clone_url }}",
71+
"git_url": "${{ github.event.repository.git_url }}",
72+
"ssh_url": "${{ github.event.repository.ssh_url }}",
73+
"url": "${{ github.event.repository.url }}",
74+
"created_at": "${{ github.event.repository.created_at }}",
75+
"updated_at": "${{ github.event.repository.updated_at }}",
76+
"pushed_at": "${{ github.event.repository.pushed_at }}",
77+
"default_branch": "${{ github.event.repository.default_branch }}",
78+
"fork": ${{ github.event.repository.fork }}
79+
},
80+
"sender": {
81+
"login": "${{ github.event.sender.login }}",
82+
"id": ${{ github.event.sender.id }},
83+
"node_id": "${{ github.event.sender.node_id }}",
84+
"avatar_url": "${{ github.event.sender.avatar_url }}",
85+
"url": "${{ github.event.sender.url }}",
86+
"html_url": "${{ github.event.sender.html_url }}",
87+
"type": "${{ github.event.sender.type }}",
88+
"site_admin": ${{ github.event.sender.site_admin }}
89+
}
90+
}
91+
EOF
92+
)
93+
94+
# Generate HMAC-SHA256 signature
95+
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" -hex | cut -d' ' -f2)
96+
97+
# Send webhook with required headers
98+
curl -X POST "$WEBHOOK_URL" \
99+
-H "Content-Type: application/json" \
100+
-H "X-GitHub-Event: release" \
101+
-H "X-GitHub-Delivery: $DELIVERY_ID" \
102+
-H "X-GitHub-Hook-ID: $HOOK_ID" \
103+
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
104+
-H "User-Agent: GitHub-Actions-Webhook/1.0" \
105+
-d "$PAYLOAD" \
106+
--fail --silent --show-error
107+
108+
echo "✅ Release webhook sent successfully"

0 commit comments

Comments
 (0)