Skip to content

Commit 01dd1ef

Browse files
Merge branch '3.1.x' into 3.2.x
2 parents 0169145 + c8b4ffc commit 01dd1ef

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Merge Dependabot PR
2+
3+
on: pull_request_target
4+
5+
run-name: Merge Dependabot PR ${{ github.ref_name }}
6+
7+
permissions: write-all
8+
9+
jobs:
10+
merge-dependabot-pr:
11+
runs-on: ubuntu-latest
12+
if: github.actor == 'dependabot[bot]'
13+
steps:
14+
15+
- uses: actions/checkout@v4
16+
with:
17+
show-progress: false
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
20+
- uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: 17
24+
25+
- name: Set Milestone to Dependabot Pull Request
26+
id: set-milestone
27+
run: |
28+
if test -f pom.xml
29+
then
30+
CURRENT_VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
31+
else
32+
CURRENT_VERSION=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }')
33+
fi
34+
export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT}
35+
MILESTONE=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.due_on != null and (.title | startswith(env.CANDIDATE_VERSION)))) | .[0] | .title')
36+
37+
if [ -z $MILESTONE ]
38+
then
39+
gh run cancel ${{ github.run_id }}
40+
echo "::warning title=Cannot merge::No scheduled milestone for $CURRENT_VERSION version"
41+
else
42+
gh pr edit ${{ github.event.pull_request.number }} --milestone $MILESTONE
43+
echo mergeEnabled=true >> $GITHUB_OUTPUT
44+
fi
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Merge Dependabot pull request
49+
if: steps.set-milestone.outputs.mergeEnabled
50+
run: gh pr merge ${{ github.event.pull_request.number }} --auto --rebase
51+
env:
52+
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}

0 commit comments

Comments
 (0)