-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from AArnott/workflowfixes
Workaround github's protections for workflow changes in GitHub Actions
- Loading branch information
Showing
1 changed file
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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: | ||
|
@@ -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 }} |