-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdependabot-retarget-to-develop.yml
More file actions
39 lines (32 loc) · 1.12 KB
/
dependabot-retarget-to-develop.yml
File metadata and controls
39 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Retarget Dependabot PRs to develop
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
permissions:
pull-requests: write
jobs:
retarget:
if: >
github.actor == 'dependabot[bot]' &&
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.state == 'open'
runs-on: ubuntu-latest
steps:
- name: Change base branch to develop
uses: actions/github-script@v9
with:
script: |
const pr = context.payload.pull_request;
// Only retarget if it is still targeting main
if (pr.base.ref !== 'main') {
core.info(`PR base is already '${pr.base.ref}', nothing to do.`);
return;
}
core.info(`Retargeting PR #${pr.number} from '${pr.base.ref}' to 'develop'...`);
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
base: 'develop',
});
core.info(`Done. PR #${pr.number} now targets 'develop'.`);