Skip to content

Commit

Permalink
add set_pr_body and refactor workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
momentmaker committed May 6, 2024
1 parent 48c0d7c commit 07f482b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/changesets-preview-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ jobs:

- name: Generate new changelog
if: steps.change.outputs.core-changeset == 'true'
id: changelog
run: pnpm install && ./tools/ci/format_changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get release version
if: steps.change.outputs.core-changeset == 'true'
id: get-release-version
run: echo "version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT

- name: Create release preview PR
if: steps.change.outputs.core-changeset == 'true'
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
Expand All @@ -64,12 +60,8 @@ jobs:
commit-message: "changeset: release preview"
committer: app-token-issuer-releng[bot] <app-token-issuer-releng[bot]@users.noreply.github.com>
branch: changesets/release-preview
title: "[DO NOT MERGE] Changeset Release Preview - v${{ steps.get-release-version.outputs.version }}"
body: |
This PR is a preview of the changes that will be included in the next release. Please do not merge this PR.
<!--
This PR was created by the changesets-release-preview workflow.
-->
title: "[DO NOT MERGE] Changeset Release Preview - v${{ steps.changelog.outputs.version }}"
body: ${{ steps.changelog.outputs.pr_body }}
draft: true
labels: |
release-preview
Expand Down
31 changes: 30 additions & 1 deletion tools/ci/format_changelog
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,35 @@ EOF
done
}

set_pr_body() {
# GitHub Issues/PRs messages have a max size limit on the message body payload.
# This is the error: `body is too long (maximum is 65536 characters)`.
max_pr_desc_char_length=65000
version=$(jq -r '.version' package.json)
echo "version=$version" >> $GITHUB_OUTPUT
read -d '' pr_header <<EOF
This PR is a preview of the changes that will be included in the next release. Please do not merge this PR.
# Chainlink Core Release - v${version}
---
EOF
if [[ ${#changelog_content} -gt $max_pr_desc_char_length ]]; then
read -d '' pr_body <<EOF
${pr_header}
The changelog content is too long for the PR description. Please view the full changelog in the [CHANGELOG.md](https://github.com/smartcontractkit/chainlink/blob/changesets/release-preview/CHANGELOG.md)
EOF
else
read -d '' pr_body <<EOF
${pr_header}
${changelog_content}
EOF
fi
echo "pr_body=$pr_body" >> $GITHUB_OUTPUT
}

set_new_changelog_content() {
append_changelog_content
read -d '' new_changelog <<EOF
${changelog_content}
${current_changelog}
Expand Down Expand Up @@ -130,5 +157,7 @@ while IFS= read -r line; do
done < CHANGELOG.md

match_tags
append_changelog_content
set_pr_body
set_new_changelog_content
cleanup

0 comments on commit 07f482b

Please sign in to comment.