Skip to content

Commit c371e18

Browse files
authored
Revert "Revert "update repo sync"" (#17935)
1 parent facad94 commit c371e18

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/allowed-actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = [
3333
"rachmari/actions-add-new-issue-to-column@1a459ef92308ba7c9c9dc2fcdd72f232495574a9",
3434
"rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e",
3535
"repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88",
36-
"repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d",
36+
"repo-sync/pull-request@65194d8015be7624d231796ddee1cd52a5023cb3", // repo-sync/[email protected]
3737
"someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd",
3838
"tjenkinson/gh-action-auto-merge-dependency-updates@4d7756c04d9d999c5968697a621b81c47f533d61",
3939
"EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575",

.github/workflows/repo-sync.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Create pull request
3434
id: create-pull
35-
uses: repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d
35+
uses: repo-sync/pull-request@65194d8015be7624d231796ddee1cd52a5023cb3
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
3838
with:
@@ -52,6 +52,22 @@ jobs:
5252
base: main
5353
author: Octomerger
5454

55+
# Sometimes the `repo-sync` branch gets created but GitHub thinks a pull
56+
# request is already attached to the branch. This may happen when an
57+
# external contributor creates a pull request for the `repo-sync` branch
58+
# in a fork, then deletes their repository. If there were changes added
59+
# to the `repo-sync` branch but no pull request can be found, we should
60+
# fail. The failure will then be sent to Slack in the last step.
61+
- name: Check for pull request creation errors
62+
if: ${{ !steps.find-pull-request.outputs.number }}
63+
id: check-pr-creation
64+
run: |
65+
LINES_CHANGED=$(git diff --name-only "main" "repo-sync" -- | wc -l | awk '{print $1}')
66+
if [[ "$LINES_CHANGED" != "0" ]]; then
67+
echo 'Unable to create a new PR for the existing branch `repo-sync`. Delete that branch and re-run this workflow to generate a new PR.'
68+
exit 1 # prevents further steps from running
69+
fi
70+
5571
- name: Approve pull request
5672
if: ${{ steps.find-pull-request.outputs.number }}
5773
uses: juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8

0 commit comments

Comments
 (0)