File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This workflow is an adaptation from https://github.com/spring-projects/spring-integration/blob/main/.github/workflows/merge-dependabot-pr.yml
2
+ # and https://github.com/spring-io/spring-github-workflows/blob/main/.github/workflows/spring-merge-dependabot-pr.yml
3
+
4
+ name : Edit Dependabot PR
5
+
6
+ on :
7
+ pull_request :
8
+
9
+ run-name : Edit Dependabot PR ${{ github.ref_name }}
10
+
11
+ env :
12
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
13
+
14
+ jobs :
15
+ edit-dependabot-pr :
16
+ runs-on : ubuntu-latest
17
+ if : github.actor == 'dependabot[bot]'
18
+ steps :
19
+
20
+ - uses : actions/checkout@v4
21
+ with :
22
+ show-progress : false
23
+
24
+ - uses : actions/setup-java@v4
25
+ with :
26
+ distribution : temurin
27
+ java-version : 17
28
+
29
+ - name : Dependabot metadata
30
+ id : metadata
31
+ uses : dependabot/fetch-metadata@v1
32
+ with :
33
+ github-token : ${{ env.GH_TOKEN }}
34
+
35
+ - name : Set Milestone to Dependabot pull request
36
+ id : set-milestone
37
+ run : |
38
+ if test -f pom.xml
39
+ then
40
+ CURRENT_VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
41
+ else
42
+ CURRENT_VERSION=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }')
43
+ fi
44
+ export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT}
45
+ MILESTONE=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.due_on != null and (.title | startswith(env.CANDIDATE_VERSION)))) | .[0] | .title')
46
+
47
+ if [ -z $MILESTONE ]
48
+ then
49
+ gh run cancel ${{ github.run_id }}
50
+ echo "::warning title=Cannot merge::No scheduled milestone for $CURRENT_VERSION version"
51
+ else
52
+ gh pr edit ${{ github.event.pull_request.number }} --milestone $MILESTONE
53
+ echo mergeEnabled=true >> $GITHUB_OUTPUT
54
+ fi
You can’t perform that action at this time.
0 commit comments