Skip to content

Commit 0e393be

Browse files
authored
devops: eliminate race condition in browser roll PR creation (#35745)
1 parent 0b6a7f5 commit 0e393be

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/roll_browser_into_playwright.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,18 @@ name: Roll Browser into Playwright
33
on:
44
repository_dispatch:
55
types: [roll_into_pw]
6-
workflow_dispatch:
7-
inputs:
8-
browser:
9-
description: 'Browser name, e.g. chromium'
10-
required: true
11-
type: string
12-
revision:
13-
description: 'Browser revision without v prefix, e.g. 1234'
14-
required: true
15-
type: string
166

177
env:
188
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
19-
BROWSER: ${{ github.event.client_payload.browser || github.event.inputs.browser }}
20-
REVISION: ${{ github.event.client_payload.revision || github.event.inputs.revision }}
9+
BROWSER: ${{ github.event.client_payload.browser }}
10+
REVISION: ${{ github.event.client_payload.revision }}
2111

2212
permissions:
2313
contents: write
2414

15+
concurrency:
16+
group: 'roll-browser-into-playwright-${{ github.event.client_payload.browser }}-${{ github.event.client_payload.revision }}'
17+
2518
jobs:
2619
roll:
2720
runs-on: ubuntu-24.04
@@ -43,6 +36,15 @@ jobs:
4336
run: |
4437
BRANCH_NAME="roll-into-pw-${BROWSER}/${REVISION}"
4538
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
39+
40+
git fetch origin $BRANCH_NAME:$BRANCH_NAME || true
41+
if git show-ref --verify --quiet refs/heads/$BRANCH_NAME; then
42+
echo "exists=1" >> $GITHUB_OUTPUT
43+
echo "branch $BRANCH_NAME already exists, exiting"
44+
exit 0
45+
fi
46+
echo "exists=0" >> $GITHUB_OUTPUT
47+
4648
git config --global user.name microsoft-playwright-automation[bot]
4749
git config --global user.email 203992400+microsoft-playwright-automation[bot]@users.noreply.github.com
4850
git checkout -b "$BRANCH_NAME"
@@ -56,6 +58,7 @@ jobs:
5658
private-key: ${{ secrets.PLAYWRIGHT_PRIVATE_KEY }}
5759
- name: Create Pull Request
5860
uses: actions/github-script@v7
61+
if: ${{ steps.prepare-branch.outputs.exists == '0' }}
5962
with:
6063
github-token: ${{ steps.app-token.outputs.token }}
6164
script: |

0 commit comments

Comments
 (0)