Skip to content

Commit 436e87c

Browse files
fix(gha): Automatically sync Readme docs version history page
1 parent b9a11d5 commit 436e87c

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
20+
# Format release notes
21+
formatted_notes="## v$release_name\n\n**($release_date)**\n\n$release_body"
22+
23+
# Get existing version history page
24+
existing_content=$(curl --request GET \
25+
--url https://dash.readme.com/api/v1/docs/ios-version-history \
26+
--header 'accept: application/json' \
27+
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
28+
| jq -r '.body')
29+
30+
# Prepend new release notes to existing content
31+
new_content=$(echo -e "$formatted_notes\n\n$existing_content")
32+
payload=$(jq -n --arg nc "$new_content" '{"body": $nc}')
33+
34+
# Update version history page with new release notes
35+
curl --request PUT \
36+
--url https://dash.readme.com/api/v1/docs/ios-version-history \
37+
--header 'accept: application/json' \
38+
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
39+
--header 'content-type: application/json' \
40+
--data "$payload"
41+
42+
- name: Announce New Release in Slack
43+
uses: slackapi/[email protected]
44+
with:
45+
channel-id: "CDFGXRM9S"
46+
payload: |
47+
{
48+
"text": "New Release: Branch iOS SDK v${{ github.event.release.tag_name }}",
49+
"blocks": [
50+
{
51+
"type": "header",
52+
"text": {
53+
"type": "plain_text",
54+
"text": ":rocket: New Release: Branch iOS SDK v${{ github.event.release.tag_name }}",
55+
"emoji": true
56+
}
57+
},
58+
{
59+
"type": "divider"
60+
},
61+
{
62+
"type": "section",
63+
"text": {
64+
"type": "mrkdwn",
65+
"text": ":star: *What's New*"
66+
}
67+
},
68+
{
69+
"type": "section",
70+
"text": {
71+
"type": "mrkdwn",
72+
"text": ${{ toJSON(github.event.release.body) }}
73+
}
74+
},
75+
{
76+
"type": "divider"
77+
},
78+
{
79+
"type": "actions",
80+
"elements": [
81+
{
82+
"type": "button",
83+
"text": {
84+
"type": "plain_text",
85+
"text": ":git: GitHub Release",
86+
"emoji": true
87+
},
88+
"value": "github",
89+
"action_id": "github",
90+
"url": "${{ github.event.release.html_url }}"
91+
}
92+
]
93+
}
94+
]
95+
}
96+
env:
97+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_SDK_BOT_TOKEN }}
98+

0 commit comments

Comments
 (0)