Branch was updated using the 'autoupdate branch' Actions workflow.
This commit is contained in:
27
.github/workflows/repo-sync.yml
vendored
27
.github/workflows/repo-sync.yml
vendored
@@ -70,6 +70,33 @@ jobs:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
number: ${{ steps.find-pull-request.outputs.number }}
|
||||
|
||||
# There are cases where the branch becomes out-of-date in between the time this workflow began and when the pull request is created/updated
|
||||
- name: Update branch
|
||||
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const mainHeadSha = await github.git.getRef({
|
||||
...context.repo,
|
||||
ref: 'heads/main'
|
||||
})
|
||||
console.log(`heads/main sha: ${mainHeadSha.data.object.sha}`)
|
||||
|
||||
const pull = await github.pulls.get({
|
||||
...context.repo,
|
||||
pull_number: ${{ steps.find-pull-request.outputs.number }}
|
||||
})
|
||||
|
||||
if (mainHeadSha.data.object.sha !== pull.data.base.sha) {
|
||||
const updateBranch = await github.pulls.updateBranch({
|
||||
...context.repo,
|
||||
pull_number: ${{ steps.find-pull-request.outputs.number }}
|
||||
})
|
||||
console.log(updateBranch.data.message)
|
||||
} else {
|
||||
console.log(`Branch is already up-to-date`)
|
||||
}
|
||||
|
||||
- name: Send Slack notification if workflow fails
|
||||
uses: someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd
|
||||
if: failure()
|
||||
|
||||
Reference in New Issue
Block a user