-
Notifications
You must be signed in to change notification settings - Fork 421
chore(ci): create pull request on changelog update #2224
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
chore(ci): create pull request on changelog update #2224
Conversation
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.
TIL that you are an expert in something else: shell scripting!
Very good @heitorlessa!!
debug "Do we have required environment variables?" | ||
test -z "${TEMP_BRANCH_PREFIX}" && raise_validation_error "TEMP_BRANCH_PREFIX env must be set to create a PR" | ||
test -z "${GH_TOKEN}" && raise_validation_error "GH_TOKEN env must be set for GitHub CLI" | ||
test -z "${GITHUB_RUN_ID}" && raise_validation_error "GITHUB_RUN_ID env must be set to trace Workflow Run ID back to PR" | ||
test -z "${GITHUB_SERVER_URL}" && raise_validation_error "GITHUB_SERVER_URL env must be set to trace Workflow Run ID back to PR" | ||
test -z "${GITHUB_REPOSITORY}" && raise_validation_error "GITHUB_REPOSITORY env must be set to trace Workflow Run ID back to PR" |
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.
Worth it adding the COMMIT_MSG
and PR_TITLE
variables in this check?
#required_env_vars :COMMIT_MSG, PR_TITLE, TEMP_BRANCH_PREFIX, GH_TOKEN, GITHUB_RUN_ID, GITHUB_SERVER_URL, GITHUB_REPOSITORY
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.
YES, good catch! Doing it now
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.
DONE
function close_duplicate_prs() { | ||
debug "Do we have any duplicate PRs?" | ||
DUPLICATE_PRS=$(gh pr list --search "${PR_TITLE}" --json number --jq ".[] | select(.number != ${NEW_PR_ID}) | .number") # e.g, 13\n14 | ||
|
||
debug "Closing duplicated PRs if any" | ||
echo "${DUPLICATE_PRS}" | xargs -L1 gh pr close --delete-branch --comment "Superseded by #${NEW_PR_ID}" | ||
export readonly DUPLICATE_PRS | ||
} |
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.
Super cool this check to avoid orphans branches in the repository and getting messy. :D
Co-authored-by: Leandro Damascena <[email protected]> Signed-off-by: Heitor Lessa <[email protected]>
Thanks @leandrodamascena for the catch and for the early approval! Merging so I can complete the related ones today. |
Issue number: closes #2210
Summary
Creates a temporary branch with CHANGELOG changes, and a pull request tracing back to GitHub Actions that originated it.
Decided to use a shell script given how powerfull GitHub CLI is now vs re-create all lower level mechanism using
JavaScript. Since all commands are CLI it made more sense to use shell script.
Changes
User experience
Pull request created
Close duplicate PRs
Cleanup behaviour
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.