-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Auto-merge non-breaking vendor updates with improved messaging #3059
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
d61a4f7
be60888
4d21982
f2e8ae5
e64c0b1
bf90303
e6fea0b
fa2a34a
570b1d6
0f6584f
cd2c4ec
4911924
2cc1125
9cfff38
e598536
82f7fdd
1afbd4a
a475de2
400cdfe
10a0675
7b86263
d495b06
f2bde61
8c0e2c5
a6f0015
1e2d8eb
ae3ed77
2ebb4f2
d11c564
6924bcb
e4ab8fb
7fdae8e
59ef29c
426d9e6
d3df508
09b0075
58ab797
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 |
|---|---|---|
|
|
@@ -31,9 +31,9 @@ jobs: | |
| - name: Summary - Workflow started | ||
| shell: pwsh | ||
| run: | | ||
| echo "## π¦ Update Vendor - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "## π¦ Vendor Update - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "Checking for vendor dependency updates..." >> $env:GITHUB_STEP_SUMMARY | ||
| echo "π Checking for vendor dependency updates..." >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
|
|
||
| - id: make-changes | ||
|
|
@@ -46,13 +46,50 @@ jobs: | |
| Set-GHVariable -Name COUNT_UPDATED -Value $count | ||
| $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) | ||
| $listUpdated = "" | ||
| $updateMessage = "| Name | Old Version | New Version |`n| :--- | ---- | ---- |`n" | ||
| $updateMessage = "| Name | Old Version | New Version | Change Type |`n| :--- | :---: | :---: | :---: |`n" | ||
| foreach ($s in $newVersion) { | ||
| $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version | ||
| if ($s.version -ne $oldVersion) { | ||
| $repoUrl = ($repoUrl = $s.Url.Replace("/archive/", "/releases/")).Substring(0, $repoUrl.IndexOf("/releases/")) + "/releases" | ||
|
|
||
| # Determine change type and emoji | ||
| $changeType = "unknown" | ||
| $emoji = "π" | ||
| try { | ||
| # Handle versions with more than 4 parts | ||
| $oldVerStr = $oldVersion.Split('-')[0] | ||
| $newVerStr = $s.version.Split('-')[0] | ||
|
|
||
| # Split by dots and take only numeric parts, first 4 max | ||
| $oldParts = $oldVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 | ||
| $newParts = $newVerStr.Split('.') | Where-Object { $_ -match '^\d+$' } | Select-Object -First 4 | ||
|
|
||
| # Ensure we have at least 2 parts (major.minor) | ||
| if ($oldParts.Count -ge 2 -and $newParts.Count -ge 2) { | ||
| $oldVerParseable = $oldParts -join '.' | ||
| $newVerParseable = $newParts -join '.' | ||
|
|
||
| $oldVer = [System.Version]::Parse($oldVerParseable) | ||
| $newVer = [System.Version]::Parse($newVerParseable) | ||
|
|
||
| if ($newVer.Major -gt $oldVer.Major) { | ||
| $changeType = "major" | ||
| $emoji = "β οΈ" | ||
| } elseif ($newVer.Minor -gt $oldVer.Minor) { | ||
| $changeType = "minor" | ||
| $emoji = "β¨" | ||
| } else { | ||
| $changeType = "patch" | ||
| $emoji = "π" | ||
| } | ||
| } | ||
| } catch { | ||
| $changeType = "unknown" | ||
| $emoji = "π" | ||
| } | ||
|
|
||
| $listUpdated += "$($s.name) v$($s.version), " | ||
| $updateMessage += "| **[$($s.name)]($repoUrl)** | $oldVersion | **$($s.version)** |`n" | ||
| $updateMessage += "| $emoji **[$($s.name)]($repoUrl)** | \`$oldVersion\` | \`$($s.version)\` | $changeType |`n" | ||
| } | ||
| } | ||
| if ($count -eq 0) { return } | ||
|
|
@@ -66,32 +103,92 @@ jobs: | |
| if ($count -eq 0) { | ||
| echo "### β No Updates Available" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "All vendor dependencies are up to date." >> $env:GITHUB_STEP_SUMMARY | ||
| echo "All vendor dependencies are up to date! π" >> $env:GITHUB_STEP_SUMMARY | ||
| } else { | ||
| $word = if ($count -eq 1) { 'dependency' } else { 'dependencies' } | ||
| $emoji = if ($count -eq 1) { 'π¦' } else { 'π¦π¦' } | ||
| echo "### π Updates Found" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "**$count** vendor $word updated:" >> $env:GITHUB_STEP_SUMMARY | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
| echo "$emoji **$count** vendor $word updated:" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "$env:UPDATE_MESSAGE" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
|
|
||
| # Check if we can auto-merge (only minor/patch changes) | ||
| $hasBreaking = $env:HAS_BREAKING_CHANGES -eq 'True' | ||
| if ($hasBreaking) { | ||
| echo "> β οΈ **Note:** This update contains major version changes that may include breaking changes." >> $env:GITHUB_STEP_SUMMARY | ||
| } else { | ||
| echo "> βΉοΈ **Note:** This update only contains minor or patch changes." >> $env:GITHUB_STEP_SUMMARY | ||
| } | ||
| } | ||
|
|
||
| - name: Auto-merge minor updates | ||
| if: env.COUNT_UPDATED > 0 && env.HAS_BREAKING_CHANGES != 'True' | ||
|
DRSDavidSoft marked this conversation as resolved.
|
||
| shell: pwsh | ||
| run: | | ||
| try { | ||
| echo "### π Auto-merging Updates" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "Attempting to automatically merge non-breaking changes to master..." >> $env:GITHUB_STEP_SUMMARY | ||
|
|
||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| # Commit the changes | ||
| git add vendor/sources.json | ||
| $commitResult = git commit -m "β¬οΈ Update dependencies ($env:LIST_UPDATED)" | ||
|
|
||
| # Push directly to master | ||
| git push origin HEAD:master | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
|
|
||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "β **Success!** Updates have been automatically merged to master." >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "**Updated dependencies:** $env:LIST_UPDATED" >> $env:GITHUB_STEP_SUMMARY | ||
|
|
||
| # Set a flag to skip PR creation | ||
| echo "AUTO_MERGED=true" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
| } catch { | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "β οΈ **Warning:** Unable to automatically merge updates." >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "**Error:** $($_.Exception.Message)" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "Falling back to creating a pull request..." >> $env:GITHUB_STEP_SUMMARY | ||
|
|
||
| Write-Warning "Failed to auto-merge: $($_.Exception.Message)" | ||
|
|
||
| # Reset only if a commit was made (check if HEAD moved) | ||
| $headBeforeReset = git rev-parse HEAD | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
| if ($commitResult) { | ||
| git reset --hard HEAD~1 | ||
| } | ||
|
Comment on lines
+221
to
+241
|
||
|
|
||
| # Set flag to create PR instead | ||
| echo "AUTO_MERGED=false" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | ||
| } | ||
|
|
||
| - uses: peter-evans/create-pull-request@v7 | ||
| if: env.COUNT_UPDATED > 0 | ||
| if: env.COUNT_UPDATED > 0 && (env.HAS_BREAKING_CHANGES == 'True' || env.AUTO_MERGED == 'false') | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
| with: | ||
| title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' | ||
| title: ${{ env.COUNT_UPDATED == '1' && format('β¬οΈ Update {0}', env.LIST_UPDATED) || format('β¬οΈ Update {0} vendored dependencies', env.COUNT_UPDATED) }} | ||
|
DRSDavidSoft marked this conversation as resolved.
Outdated
DRSDavidSoft marked this conversation as resolved.
Outdated
|
||
| body: | | ||
| ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: | ||
|
DRSDavidSoft marked this conversation as resolved.
|
||
| ### ${{ env.COUNT_UPDATED == '1' && 'π¦ Automatically updated 1 dependency' || format('π¦ Automatically updated {0} dependencies', env.COUNT_UPDATED) }} | ||
|
|
||
| ${{ env.UPDATE_MESSAGE }} | ||
|
|
||
| --- | ||
| Please verify and then **Merge** the pull request to update. | ||
|
|
||
| ${{ env.HAS_BREAKING_CHANGES == 'True' && 'β οΈ **This update contains major version changes that may include breaking changes.**' || 'βΉοΈ This update only contains minor or patch changes.' }} | ||
|
|
||
| Please verify and then **Merge** the pull request to apply the updates. | ||
| commit-message: 'β¬οΈ Update dependencies (${{ env.LIST_UPDATED }})' | ||
| branch: update-vendor | ||
| base: master | ||
|
|
||
| - name: Summary - Pull request created | ||
| if: env.COUNT_UPDATED > 0 | ||
| if: env.COUNT_UPDATED > 0 && (env.HAS_BREAKING_CHANGES == 'True' || env.AUTO_MERGED == 'false') | ||
|
DRSDavidSoft marked this conversation as resolved.
|
||
| shell: pwsh | ||
| run: | | ||
| echo "### π Pull Request Created" >> $env:GITHUB_STEP_SUMMARY | ||
|
|
@@ -102,4 +199,10 @@ jobs: | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "**Updated dependencies:** $env:LIST_UPDATED" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "> Please review and merge the pull request to apply the updates." >> $env:GITHUB_STEP_SUMMARY | ||
| if ($env:HAS_BREAKING_CHANGES -eq 'True') { | ||
| echo "> β οΈ **Manual review required:** This update contains major version changes." >> $env:GITHUB_STEP_SUMMARY | ||
| } else { | ||
| echo "> βΉοΈ **Note:** Auto-merge failed, manual review required." >> $env:GITHUB_STEP_SUMMARY | ||
| } | ||
| echo "" >> $env:GITHUB_STEP_SUMMARY | ||
| echo "Please review and merge the pull request to apply the updates." >> $env:GITHUB_STEP_SUMMARY | ||
Uh oh!
There was an error while loading. Please reload this page.