Skip to content

Commit 87721c1

Browse files
authored
Create slack_release_notes.yml (#50)
1 parent eed179d commit 87721c1

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Notify Slack on Latest Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
notify-slack:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Fetch latest published release
14+
id: get_release
15+
run: |
16+
echo "🔍 Getting latest published release..."
17+
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
18+
-H "Accept: application/vnd.github+json" \
19+
https://api.github.com/repos/${{ github.repository }}/releases \
20+
| jq '[.[] | select(.draft == false and .prerelease == false)][0]' > release.json
21+
22+
echo "RELEASE_NAME<<EOF" >> $GITHUB_ENV
23+
jq -r .name release.json >> $GITHUB_ENV
24+
echo "EOF" >> $GITHUB_ENV
25+
26+
echo "RELEASE_URL<<EOF" >> $GITHUB_ENV
27+
jq -r .html_url release.json >> $GITHUB_ENV
28+
echo "EOF" >> $GITHUB_ENV
29+
30+
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
31+
jq -r .body release.json >> $GITHUB_ENV
32+
echo "EOF" >> $GITHUB_ENV
33+
34+
- name: Print resolved values (debug)
35+
run: |
36+
echo "RELEASE_NAME: $RELEASE_NAME"
37+
echo "RELEASE_URL: $RELEASE_URL"
38+
echo "RELEASE_BODY:"
39+
echo "$RELEASE_BODY"
40+
41+
- name: Send release info to Slack
42+
run: |
43+
pip install slack-sdk markdown2slack
44+
python3 << 'EOF'
45+
import os
46+
from slack_sdk.webhook import WebhookClient
47+
from markdown2slack.app import Convert
48+
49+
# Create converter instance
50+
converter = Convert()
51+
52+
webhook = WebhookClient(os.environ['SLACK_WEBHOOK_URL'])
53+
54+
# Convert markdown to Slack format
55+
slack_formatted = converter.markdown_to_slack_format(os.environ['RELEASE_BODY'])
56+
57+
response = webhook.send(
58+
text=f"New release published: {os.environ['RELEASE_NAME']}",
59+
blocks=[
60+
{
61+
"type": "section",
62+
"text": {
63+
"type": "mrkdwn",
64+
"text": f"*New EDU Release:* <{os.environ['RELEASE_URL']}|{os.environ['RELEASE_NAME']}>"
65+
}
66+
},
67+
{
68+
"type": "divider"
69+
},
70+
{
71+
"type": "section",
72+
"text": {
73+
"type": "mrkdwn",
74+
"text": slack_formatted
75+
}
76+
}
77+
]
78+
)
79+
print(f"Response: {response.status_code}")
80+
EOF
81+
env:
82+
RELEASE_NAME: ${{ env.RELEASE_NAME }}
83+
RELEASE_URL: ${{ env.RELEASE_URL }}
84+
RELEASE_BODY: ${{ env.RELEASE_BODY }}
85+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)