Skip to content

Commit

Permalink
Use outputs for capturing release-notes (#833)
Browse files Browse the repository at this point in the history
frederikprijck authored Dec 13, 2023
2 parents 20c7a50 + 5744d43 commit bb6ef13
Showing 2 changed files with 19 additions and 22 deletions.
39 changes: 18 additions & 21 deletions .github/actions/get-release-notes/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Return the release notes extracted from the PR body

#
# Returns the release notes from the content of a pull request linked to a release branch. It expects the branch name to be in the format release/vX.Y.Z, release/X.Y.Z, release/vX.Y.Z-beta.N. etc.
#
# TODO: Remove once the common repo is public.
#
inputs:
version :
version:
required: true
repo_name:
required: false
@@ -15,30 +14,28 @@ inputs:
token:
required: true

outputs:
release-notes:
value: ${{ steps.get_release_notes.outputs.RELEASE_NOTES }}

runs:
using: composite

steps:
- id: get_release_notes
shell: bash
run: |
RELEASE_PR_BRANCH="release/$VERSION"
API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls"
RELEASE_NOTES=$(curl -G \
-H "Accept: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
--data-urlencode "state=all" \
--data-urlencode "head=$REPO_OWNER:$RELEASE_PR_BRANCH" \
"$API_URL" | jq -r ".[0].body"
)
{
echo 'RELEASE_NOTES<<EOF'
echo $RELEASE_NOTES
echo 'EOF'
} >> $GITHUB_ENV
- uses: actions/github-script@v7
id: get_release_notes
with:
result-encoding: string
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: process.env.REPO_OWNER,
repo: process.env.REPO_NAME,
state: 'all',
head: `${process.env.REPO_OWNER}:release/${process.env.VERSION}`,
});
core.setOutput('RELEASE_NOTES', pulls[0].body);
env:
GITHUB_TOKEN: ${{ inputs.token }}
REPO_OWNER: ${{ inputs.repo_owner }}
REPO_NAME: ${{ inputs.repo_name }}
VERSION: ${{ inputs.version }}
VERSION: ${{ inputs.version }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.get_version.outputs.version }}
body: ${{ env.RELEASE_NOTES }}
body: ${{ steps.get_release_notes.outputs.release-notes }}
tag: ${{ steps.get_version.outputs.version }}
commit: ${{ github.sha }}
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}

0 comments on commit bb6ef13

Please sign in to comment.