File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-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
+ permissions : write-all
19
+ steps :
20
+
21
+ - uses : actions/checkout@v4
22
+ with :
23
+ show-progress : false
24
+
25
+ - uses : actions/setup-java@v4
26
+ with :
27
+ distribution : temurin
28
+ java-version : 17
29
+
30
+ - name : Dependabot metadata
31
+ id : metadata
32
+ uses : dependabot/fetch-metadata@v1
33
+ with :
34
+ github-token : ${{ env.GH_TOKEN }}
35
+
36
+ - name : Set Milestone to Dependabot pull request
37
+ id : set-milestone
38
+ run : |
39
+ if test -f pom.xml
40
+ then
41
+ CURRENT_VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
42
+ else
43
+ CURRENT_VERSION=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }')
44
+ fi
45
+ export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT}
46
+ MILESTONE=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.due_on != null and (.title | startswith(env.CANDIDATE_VERSION)))) | .[0] | .title')
47
+
48
+ if [ -z $MILESTONE ]
49
+ then
50
+ gh run cancel ${{ github.run_id }}
51
+ echo "::warning title=Cannot merge::No scheduled milestone for $CURRENT_VERSION version"
52
+ else
53
+ gh pr edit ${{ github.event.pull_request.number }} --milestone $MILESTONE
54
+ echo mergeEnabled=true >> $GITHUB_OUTPUT
55
+ fi
You can’t perform that action at this time.
0 commit comments