-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Validate supplied branch and tag exist for RN gen #18481
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
Validate supplied branch and tag exist for RN gen #18481
Conversation
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.
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label. Could you fix it @donoghuc? 🙏
|
| fetch-depth: 0 | ||
| - name: Validate the supplied target branch and last release tag exist | ||
| run: | | ||
| git fetch --tags | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if you want to use the more native github approach, although https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches.
but I think
# Whether to fetch tags, even if fetch-depth > 0.
# Default: false
fetch-tags: ''
| fetch-depth: 0 | |
| - name: Validate the supplied target branch and last release tag exist | |
| run: | | |
| git fetch --tags | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Validate the supplied target branch and last release tag exist | |
| run: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, right. Good call.
| if ! git rev-parse --verify "origin/${{ github.event.inputs.branch }}" >/dev/null 2>&1; then | ||
| echo "Error: Branch ${{ github.event.inputs.branch }} does not exist" | ||
| exit 1 | ||
| fi | ||
| if ! git rev-parse --verify "v${{ github.event.inputs.last_release }}" >/dev/null 2>&1; then | ||
| echo "Error: Tag v${{ github.event.inputs.last_release }} does not exist" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use intermediate env variables for inputs as explained in the security hardening:
| if ! git rev-parse --verify "origin/${{ github.event.inputs.branch }}" >/dev/null 2>&1; then | |
| echo "Error: Branch ${{ github.event.inputs.branch }} does not exist" | |
| exit 1 | |
| fi | |
| if ! git rev-parse --verify "v${{ github.event.inputs.last_release }}" >/dev/null 2>&1; then | |
| echo "Error: Tag v${{ github.event.inputs.last_release }} does not exist" | |
| exit 1 | |
| fi | |
| if ! git rev-parse --verify "origin/${BRANCH}" >/dev/null 2>&1; then | |
| echo "Error: Branch ${BRANCH} does not exist" | |
| exit 1 | |
| fi | |
| if ! git rev-parse --verify "v${LAST_RELEASE}" >/dev/null 2>&1; then | |
| echo "Error: Tag v${LAST_RELEASE} does not exist" | |
| exit 1 | |
| fi | |
| env: | |
| LAST_RELEASE: ${{ inputs.last_release }} | |
| BRANCH: ${{ inputs.branch }} |
Maybe these env variables should be created a the job-level so it can be used in other steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with your last thought (ENV vars at job level).
Use action for fetching tags and env vars for looking up inputs
|
Run showing validation is working (fails when tag does not exist): https://github.com/elastic/logstash/actions/runs/20114283936 |
Release notes
[rn:skip]
What does this PR do?
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.