-
Notifications
You must be signed in to change notification settings - Fork 13
Fix errors in update-spring-dependencies.yml
#51
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
Changes from 2 commits
1f7472b
956213d
7e6be6f
2c59b99
0e5d68b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,40 @@ jobs: | |
| git add -A | ||
| git commit -m "Upgrade external dependencies to align with Spring Boot ${{ env.spring_boot_version }}" | ||
| git push "https://${{ secrets.USER }}:${{ secrets.ACCESS_TOKEN }}@github.com/${{ secrets.USER }}/azure-sdk-for-java.git" "HEAD:${{ env.update_branch }}" | ||
| - name: Close Old Pull Requests | ||
| if: ${{ env.need_update_version == 'true' }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.ACCESS_TOKEN }} | ||
| script: | | ||
| const prTitlePrefix = 'External dependencies upgrade - Spring Boot'; | ||
| const { data: pullRequests } = await github.rest.pulls.list({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| state: 'open', | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const oldPRs = pullRequests.filter(pr => pr.title.startsWith(prTitlePrefix)); | ||
|
|
||
| for (const pr of oldPRs) { | ||
| console.log(`Closing PR #${pr.number} with comment`); | ||
| await github.rest.issues.createComment({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| issue_number: pr.number, | ||
| body: 'This PR has been superseded by a newer update. Closing automatically.' | ||
| }); | ||
|
|
||
| await github.rest.pulls.update({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| pull_number: pr.number, | ||
| state: 'closed' | ||
| }); | ||
| } | ||
| - name: Create Pull Request | ||
| id: create_pr | ||
| if: ${{ env.need_update_version == 'true' }} | ||
| uses: vsoch/pull-request-action@master | ||
| env: | ||
|
|
@@ -99,42 +132,19 @@ jobs: | |
| with: | ||
| github-token: ${{ secrets.ACCESS_TOKEN }} | ||
| script: | | ||
| const { data: pullRequests } = await github.rest.pulls.list({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| state: 'open', | ||
| per_page: 100 | ||
| }); | ||
| const prNumber = '${{ steps.create_pr.outputs.pull_request_number }}'; | ||
|
|
||
| const prTitlePrefix = 'External dependencies upgrade - Spring Boot'; | ||
| const matchingPRs = pullRequests | ||
| .filter(pr => pr.title.startsWith(prTitlePrefix)) | ||
| .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | ||
|
|
||
| if (matchingPRs.length <= 1) { | ||
| console.log('No old pull requests found to comment on.'); | ||
| if (!prNumber) { | ||
| console.log('No pull request was created, nothing to comment on.'); | ||
| return; | ||
| } | ||
|
|
||
| const latestPR = matchingPRs[0]; | ||
| const comment1 = `/azp run java - spring - tests`; | ||
| console.log(`Commenting on latest PR #${latestPR.number}`); | ||
|
|
||
| console.log(`Commenting on PR #${prNumber}`); | ||
| await github.rest.issues.createComment({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| issue_number: latestPR.number, | ||
| body: comment1 | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| issue_number: prNumber, | ||
| body: comment1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment not works: Azure/azure-sdk-for-java#49502 (comment)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the comment said, it's caused by adding new commits after adding this comment, it's not caused by the error of current file, we can ignore it. |
||
| }); | ||
|
|
||
| const comment2 = `A newer update PR has been created: #${latestPR.number} (${latestPR.html_url}). Please track updates there.`; | ||
|
|
||
| for (const pr of matchingPRs.slice(1)) { | ||
| console.log(`Commenting on old PR #${pr.number}`); | ||
| await github.rest.issues.createComment({ | ||
| owner: 'Azure', | ||
| repo: 'azure-sdk-for-java', | ||
| issue_number: pr.number, | ||
| body: comment2 | ||
| }); | ||
| } | ||
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.
it will close the working PR: Azure/azure-sdk-for-java#49501
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.
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.
Not it will skip other steps if there is any PR with specific title prefix. Here are test pipelines:
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.
can remove this step 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.
Removed