3 changed files with 33 additions and 55 deletions
@ -1,55 +0,0 @@ |
|||||||
# 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]' |
|
||||||
permissions: write-all |
|
||||||
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 |
|
||||||
@ -0,0 +1,13 @@ |
|||||||
|
name: Merge Dependabot PR |
||||||
|
|
||||||
|
on: |
||||||
|
pull_request: |
||||||
|
|
||||||
|
run-name: Merge Dependabot PR ${{ github.ref_name }} |
||||||
|
|
||||||
|
jobs: |
||||||
|
merge-dependabot-pr: |
||||||
|
permissions: write-all |
||||||
|
uses: spring-io/spring-github-workflows/.github/workflows/spring-merge-dependabot-pr.yml@v2 |
||||||
|
with: |
||||||
|
mergeArguments: '--auto --rebase' |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
name: Trigger Dependabot Auto Merge Forward |
||||||
|
|
||||||
|
on: |
||||||
|
push: |
||||||
|
|
||||||
|
permissions: read-all |
||||||
|
|
||||||
|
jobs: |
||||||
|
trigger-worflow: |
||||||
|
name: Trigger Workflow |
||||||
|
runs-on: ubuntu-latest |
||||||
|
if: github.event.commits[0].author.username == 'dependabot[bot]' |
||||||
|
steps: |
||||||
|
- name: Checkout |
||||||
|
id: checkout |
||||||
|
uses: actions/checkout@v4 |
||||||
|
- id: trigger |
||||||
|
env: |
||||||
|
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} |
||||||
|
run: gh workflow run dependabot-auto-merge-forward.yml -r main |
||||||
Loading…
Reference in new issue