Skip to content

Commit 5252c04

Browse files
authored
Merge pull request #3527 from beefproject/red/fix_dependabot_automerge
Separate the concerns: dependabot and manual PR labelling for testing
2 parents 27547ac + 6b1af1e commit 5252c04

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Auto-label Dependabot PRs'
2+
3+
on:
4+
pull_request_target:
5+
branches: [ master ]
6+
types: [ opened, synchronize ]
7+
8+
jobs:
9+
auto-label:
10+
name: 'Apply safe_to_test for Dependabot'
11+
if: github.event.pull_request.user.login == 'dependabot[bot]'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: 'Add safe_to_test label'
15+
uses: actions/github-script@v8
16+
with:
17+
script: |
18+
const { owner, repo } = context.repo;
19+
const issue_number = context.payload.pull_request.number;
20+
21+
// Remove first so re-adding always fires a labeled event,
22+
// which triggers the BrowserStack workflow.
23+
try {
24+
await github.rest.issues.removeLabel({
25+
owner, repo, issue_number,
26+
name: 'safe_to_test'
27+
});
28+
} catch (e) {
29+
if (e.status !== 404) throw e;
30+
}
31+
32+
await github.rest.issues.addLabels({
33+
owner, repo, issue_number,
34+
labels: ['safe_to_test']
35+
});

.github/workflows/github_actions.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: 'BrowserStack Test'
33
on:
44
pull_request_target:
55
branches: [ master ]
6-
types: [ labeled, opened, synchronize ]
6+
types: [ labeled ]
77

88
jobs:
99
ubuntu-job:
@@ -12,15 +12,12 @@ jobs:
1212
concurrency:
1313
group: browserstack-${{ github.event.pull_request.number }}
1414
cancel-in-progress: true
15-
if: |
16-
github.event.label.name == 'safe_to_test' ||
17-
github.event.pull_request.user.login == 'dependabot[bot]'
15+
if: github.event.label.name == 'safe_to_test'
1816
env:
1917
GITACTIONS: true
2018
steps:
2119

2220
- name: 'Remove safe_to_test label'
23-
if: github.event.label.name == 'safe_to_test'
2421
uses: actions/github-script@v8
2522
with:
2623
script: |
@@ -79,4 +76,4 @@ jobs:
7976
- name: 'BrowserStackLocal Stop' # Terminating the BrowserStackLocal tunnel connection
8077
uses: browserstack/github-actions/setup-local@master
8178
with:
82-
local-testing: stop
79+
local-testing: stop

0 commit comments

Comments
 (0)