Skip to content

Commit eeb2b59

Browse files
authored
fix repo-sync bug (#17047)
* fix repo-sync bug * add another log * add mergeable_state check * check for pull number * add check for prior steps * remove test logs * lint
1 parent 9a0222e commit eeb2b59

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

.github/workflows/repo-sync.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
github_token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
4545

4646
- name: Create pull request
47+
id: create-pull
4748
uses: repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d
4849
env:
4950
GITHUB_TOKEN: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
@@ -72,9 +73,10 @@ jobs:
7273

7374
# 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
7475
- name: Update branch
76+
if: ${{ steps.find-pull-request.outputs.number }}
7577
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
7678
with:
77-
github-token: ${{secrets.GITHUB_TOKEN}}
79+
github-token: ${{ secrets.GITHUB_TOKEN }}
7880
script: |
7981
const mainHeadSha = await github.git.getRef({
8082
...context.repo,
@@ -84,13 +86,14 @@ jobs:
8486
8587
const pull = await github.pulls.get({
8688
...context.repo,
87-
pull_number: ${{ steps.find-pull-request.outputs.number }}
89+
pull_number: parseInt(${{ steps.find-pull-request.outputs.number }})
8890
})
91+
console.log(`Pull request base sha: ${pull.data.base.sha}`)
8992
90-
if (mainHeadSha.data.object.sha !== pull.data.base.sha) {
93+
if (mainHeadSha.data.object.sha !== pull.data.base.sha || pull.data.mergeable_state === 'behind') {
9194
const updateBranch = await github.pulls.updateBranch({
9295
...context.repo,
93-
pull_number: ${{ steps.find-pull-request.outputs.number }}
96+
pull_number: parseInt(${{ steps.find-pull-request.outputs.number }})
9497
})
9598
console.log(updateBranch.data.message)
9699
} else {

0 commit comments

Comments
 (0)