Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-2072] Create GHA to sync release notes with ReadMe Version History #931

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/sync-readme-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Update Version History on Readme

on:
release:
types: [published]

jobs:
update-changelog:
runs-on: ubuntu-latest

steps:
- name: Format and publish release notes to version history doc
id: update
run: |
# Get release name, body, and date from the release event
release_name="${{ github.event.release.tag_name }}"
release_body="${{ github.event.release.body }}"
release_date=$(date -d "${{ github.event.release.published_at }}" +"%Y-%B-%d")
# Format release notes
formatted_notes="## $release_name\n\n**($release_date)**\n\n$release_body"

# Get existing version history page
existing_content=$(curl --request GET \
--url https://dash.readme.com/api/v1/docs/web-version-history \
--header 'accept: application/json' \
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
| jq -r '.body')

# Prepend new release notes to existing content
new_content=$(echo -e "$formatted_notes\n\n$existing_content")
payload=$(jq -n --arg nc "$new_content" '{"body": $nc}')

# Update version history page with new release notes
curl --request PUT \
--url https://dash.readme.com/api/v1/docs/web-version-history \
--header 'accept: application/json' \
--header "authorization: Basic ${{ secrets.readme_api_key_base64 }}" \
--header 'content-type: application/json' \
--data "$payload"

- name: Announce New Release in Slack
uses: slackapi/[email protected]
with:
channel-id: "CDFGXRM9S"
payload: |
{
"text": "New Release: Branch Web SDK ${{ github.event.release.tag_name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rocket: New Release: Branch Web SDK ${{ github.event.release.tag_name }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":star: *What's New*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(github.event.release.body) }}
}
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":git: GitHub Release",
"emoji": true
},
"value": "github",
"action_id": "github",
"url": "${{ github.event.release.html_url }}"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_SDK_BOT_TOKEN }}