Skip to content

Commit ce035be

Browse files
Create sync-readme-changelog.yml (#931)
1 parent 802e68a commit ce035be

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Update Version History on Readme
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-changelog:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Format and publish release notes to version history doc
13+
id: update
14+
run: |
15+
# Get release name, body, and date from the release event
16+
release_name="${{ github.event.release.tag_name }}"
17+
release_body="${{ github.event.release.body }}"
18+
release_date=$(date -d "${{ github.event.release.published_at }}" +"%Y-%B-%d")
19+
# Format release notes
20+
formatted_notes="## $release_name\n\n**($release_date)**\n\n$release_body"
21+
22+
# Get existing version history page
23+
existing_content=$(curl --request GET \
24+
--url https://dash.readme.com/api/v1/docs/web-version-history \
25+
--header 'accept: application/json' \
26+
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
27+
| jq -r '.body')
28+
29+
# Prepend new release notes to existing content
30+
new_content=$(echo -e "$formatted_notes\n\n$existing_content")
31+
payload=$(jq -n --arg nc "$new_content" '{"body": $nc}')
32+
33+
# Update version history page with new release notes
34+
curl --request PUT \
35+
--url https://dash.readme.com/api/v1/docs/web-version-history \
36+
--header 'accept: application/json' \
37+
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
38+
--header 'content-type: application/json' \
39+
--data "$payload"
40+
41+
- name: Announce New Release in Slack
42+
uses: slackapi/[email protected]
43+
with:
44+
channel-id: "CDFGXRM9S"
45+
payload: |
46+
{
47+
"text": "New Release: Branch Web SDK ${{ github.event.release.tag_name }}",
48+
"blocks": [
49+
{
50+
"type": "header",
51+
"text": {
52+
"type": "plain_text",
53+
"text": ":rocket: New Release: Branch Web SDK ${{ github.event.release.tag_name }}",
54+
"emoji": true
55+
}
56+
},
57+
{
58+
"type": "divider"
59+
},
60+
{
61+
"type": "section",
62+
"text": {
63+
"type": "mrkdwn",
64+
"text": ":star: *What's New*"
65+
}
66+
},
67+
{
68+
"type": "section",
69+
"text": {
70+
"type": "mrkdwn",
71+
"text": ${{ toJSON(github.event.release.body) }}
72+
}
73+
},
74+
{
75+
"type": "divider"
76+
},
77+
{
78+
"type": "actions",
79+
"elements": [
80+
{
81+
"type": "button",
82+
"text": {
83+
"type": "plain_text",
84+
"text": ":git: GitHub Release",
85+
"emoji": true
86+
},
87+
"value": "github",
88+
"action_id": "github",
89+
"url": "${{ github.event.release.html_url }}"
90+
}
91+
]
92+
}
93+
]
94+
}
95+
env:
96+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_SDK_BOT_TOKEN }}

0 commit comments

Comments
 (0)