1 changed files with 54 additions and 0 deletions
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
# This workflow is an adaptation from https://github.com/spring-projects/spring-integration/blob/main/.github/workflows/merge-dependabot-pr.yml |
||||
# and https://github.com/spring-io/spring-github-workflows/blob/main/.github/workflows/spring-merge-dependabot-pr.yml |
||||
|
||||
name: Edit Dependabot PR |
||||
|
||||
on: |
||||
pull_request: |
||||
|
||||
run-name: Edit Dependabot PR ${{ github.ref_name }} |
||||
|
||||
env: |
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
jobs: |
||||
edit-dependabot-pr: |
||||
runs-on: ubuntu-latest |
||||
if: github.actor == 'dependabot[bot]' |
||||
steps: |
||||
|
||||
- uses: actions/checkout@v4 |
||||
with: |
||||
show-progress: false |
||||
|
||||
- uses: actions/setup-java@v4 |
||||
with: |
||||
distribution: temurin |
||||
java-version: 17 |
||||
|
||||
- name: Dependabot metadata |
||||
id: metadata |
||||
uses: dependabot/fetch-metadata@v1 |
||||
with: |
||||
github-token: ${{ env.GH_TOKEN }} |
||||
|
||||
- name: Set Milestone to Dependabot pull request |
||||
id: set-milestone |
||||
run: | |
||||
if test -f pom.xml |
||||
then |
||||
CURRENT_VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout) |
||||
else |
||||
CURRENT_VERSION=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }') |
||||
fi |
||||
export CANDIDATE_VERSION=${CURRENT_VERSION/-SNAPSHOT} |
||||
MILESTONE=$(gh api repos/$GITHUB_REPOSITORY/milestones --jq 'map(select(.due_on != null and (.title | startswith(env.CANDIDATE_VERSION)))) | .[0] | .title') |
||||
|
||||
if [ -z $MILESTONE ] |
||||
then |
||||
gh run cancel ${{ github.run_id }} |
||||
echo "::warning title=Cannot merge::No scheduled milestone for $CURRENT_VERSION version" |
||||
else |
||||
gh pr edit ${{ github.event.pull_request.number }} --milestone $MILESTONE |
||||
echo mergeEnabled=true >> $GITHUB_OUTPUT |
||||
fi |
||||
Loading…
Reference in new issue