WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit cfa4fb9

Browse files
authored
Validate supplied branch and tag exist for RN gen (#18481)
* Validate supplied branch and tag exist for RN gen Add a validation step to the action for generating release notes. Without input validation tags/branches that do not exist (due to typo, errors in workflow inputs) can go un-noticed with PRs that have empty commit ranges. * Codereview feedback application Use action for fetching tags and env vars for looking up inputs
1 parent e08abb8 commit cfa4fb9

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

.github/workflows/gen_release_notes.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,26 @@ permissions:
2121
jobs:
2222
main:
2323
runs-on: ubuntu-latest
24+
env:
25+
BRANCH: ${{ github.event.inputs.branch }}
26+
LAST_RELEASE: ${{ github.event.inputs.last_release }}
27+
ACTOR: ${{ github.actor }}
2428
steps:
2529
- uses: actions/checkout@v6
2630
with:
2731
fetch-depth: 0
32+
fetch-tags: true
33+
- name: Validate the supplied target branch and last release tag exist
34+
run: |
35+
if ! git rev-parse --verify "origin/${BRANCH}" >/dev/null 2>&1; then
36+
echo "Error: Branch ${BRANCH} does not exist"
37+
exit 1
38+
fi
39+
40+
if ! git rev-parse --verify "v${LAST_RELEASE}" >/dev/null 2>&1; then
41+
echo "Error: Tag v${LAST_RELEASE} does not exist"
42+
exit 1
43+
fi
2844
- name: Set up Ruby
2945
uses: ruby/setup-ruby@v1
3046
with:
@@ -33,12 +49,12 @@ jobs:
3349
- run: git config --global user.name "logstashmachine"
3450
- name: Create Release Notes Draft
3551
run: |
36-
if [[ "${{ github.event.inputs.branch }}" =~ ^([0-8])\.[0-9]+$ ]]; then
52+
if [[ "${BRANCH}" =~ ^([0-8])\.[0-9]+$ ]]; then
3753
echo "Using Asciidoc generator"
3854
SCRIPT="./tools/release/generate_release_notes.rb"
3955
else
4056
echo "Using Markdown generator"
4157
SCRIPT="./tools/release/generate_release_notes_md.rb"
4258
fi
43-
44-
$SCRIPT "${{ github.event.inputs.branch }}" "${{ github.event.inputs.last_release }}" "${{ github.actor }}" "${{ secrets.GITHUB_TOKEN }}"
59+
60+
$SCRIPT "${BRANCH}" "${LAST_RELEASE}" "${ACTOR}" "${{ secrets.GITHUB_TOKEN }}"

0 commit comments

Comments
 (0)