-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add workflow for updating durations #6519
base: master
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
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.
Overall looks good! Would we be able to test this within this PR? Maybe temporarily add the pull_request
trigger and then remove? (or has testing already been done?)
Other than that, LGTM
@rashidnhm I linked a workflow run in the description of this PR. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6519 +/- ##
==========================================
- Coverage 99.65% 99.34% -0.32%
==========================================
Files 455 455
Lines 43193 43193
==========================================
- Hits 43044 42909 -135
- Misses 149 284 +135 ☔ View full report in Codecov by Sentry. |
PR_BODY: ${{ inputs.pull_request_body }} | ||
run: | | ||
EXISTING_PR="$(gh pr list --state open --base master --head $HEAD_BRANCH_NAME --json 'url' --jq '.[].url' | head -n 1)" | ||
EXISTING_CLOSED_PR="$(gh pr list --state closed --base master --head $HEAD_BRANCH_NAME --json 'mergedAt,url' --jq '.[] | select(.mergedAt == null).url' | head -n 1)" | ||
|
||
if [ -n "${EXISTING_PR}" ]; then | ||
echo "PR already exists ==> ${EXISTING_PR}" | ||
echo "Open PR already exists ==> ${EXISTING_PR" | ||
echo "Editing with provided title and body..." | ||
gh pr edit --title "$PR_TITLE" --body "$PR_BODY" | ||
exit 0 | ||
elif [ -n "${EXISTING_CLOSED_PR}" ] && [ ${{ steps.prep_commit.outputs.branch_exists }}=='true' ]; then | ||
echo "Reopening PR... ${EXISTING_CLOSED_PR}" | ||
gh pr reopen "${EXISTING_CLOSED_PR}" | ||
echo "Editing with provided title and body..." | ||
gh pr edit --title "$PR_TITLE" --body "$PR_BODY" | ||
exit 0 | ||
else | ||
echo "Creating PR..." | ||
gh pr create --title "$PR_TITLE" --body "$PR_BODY" | ||
exit 0 | ||
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.
The new logic does the following:
- If there is an existing PR, just edit the title and body with what was given as inputs to this action and do nothing else
- Else if there is a closed PR and the branch for the closed PR was not deleted, then reopen the PR and edit the title and body. I added the 2nd condition because the reopen command failed on an old run when the branch of the closed PR had been deleted and we had to create a new branch.
- Else, open a new PR with the provided title and body
EXISTING_BRANCH=$(git ls-remote --exit-code origin "refs/heads/$HEAD_BRANCH_NAME") | ||
|
||
if [ -n $EXISTING_BRANCH ]; then | ||
echo "$HEAD_BRANCH_NAME exists! Checking out..." | ||
git checkout "$HEAD_BRANCH_NAME" | ||
echo "branch_exists='true'" >> $GITHUB_OUTPUT | ||
else | ||
echo "$HEAD_BRANCH_NAME does not exist! Creating..." | ||
git checkout -b "$HEAD_BRANCH_NAME" | ||
echo "branch_exists='false'" >> $GITHUB_OUTPUT |
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.
branch_exists
, a new output of this step which happens before the step that creates a PR, is used for the 2nd condition in the previous comment.
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.
Overall looks good, is the stash method working consistently now?
@rashidnhm Yep, it's working well 😄 . I got it to work by using |
Co-authored-by: Rashid N H M <[email protected]>
Third attempt at creating a workflow that updates the durations files automatically.
Working workflow run here
PR opened by workflow here
[sc-72992]