Skip to content

Commit

Permalink
Merge pull request #309 from AArnott/workflowfixes
Browse files Browse the repository at this point in the history
Workaround github's protections for workflow changes in GitHub Actions
  • Loading branch information
AArnott authored Nov 13, 2024
2 parents 0683b79 + 77ef017 commit 61efb71
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/libtemplate-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ jobs:
exit 0
}
git -c http.extraheader="AUTHORIZATION: bearer $env:GH_TOKEN" push origin -u FETCH_HEAD:refs/heads/auto/libtemplateUpdate
# Pushing commits that add or change files under .github/workflows will cause our workflow to fail.
# But it usually isn't necessary because the target branch already has (or doesn't have) these changes.
# So if the merged doesn't bring in any changes to these files, try the merge locally and push that
# to keep github happy.
if ((git rev-list FETCH_HEAD ^HEAD --count -- .github/workflows) -eq 0) {
# Indeed there are no changes in that area. So merge locally to try to appease GitHub.
git checkout -b auto/libtemplateUpdate
git config user.name "Andrew Arnott"
git config user.email "[email protected]"
git merge FETCH_HEAD
if ($LASTEXITCODE -ne 0) {
Write-Host "Merge conflicts prevent creating the pull request. Please run tools/MergeFrom-Template.ps1 locally and push the result as a pull request."
exit 2
}
git -c http.extraheader="AUTHORIZATION: bearer $env:GH_TOKEN" push origin -u HEAD
} else {
Write-Host "Changes to github workflows are included in this update. Please run tools/MergeFrom-Template.ps1 locally and push the result as a pull request."
exit 1
}
- name: pull request
shell: pwsh
if: success() && steps.merge.outputs.uptodate != 'true'
Expand All @@ -58,6 +77,8 @@ jobs:
$prTitle = "Merge latest Library.Template"
$prBody = "This merges the latest features and fixes from [Library.Template's branch](https://github.com/AArnott/Library.Template/tree/).
⚠️ Do **not** squash this pull request when completing it. You must *merge* it."
<details>
<summary>Merge conflicts?</summary>
Resolve merge conflicts locally by carrying out these steps:
Expand All @@ -72,8 +93,6 @@ jobs:
```
</details>
⚠️ Do **not** squash this pull request when completing it. You must *merge* it."
gh pr create -H auto/libtemplateUpdate -b $prBody -t $prTitle
env:
GH_TOKEN: ${{ github.token }}

0 comments on commit 61efb71

Please sign in to comment.