Skip to content

Commit 1be06fe

Browse files
committed
Dependabot PR merge WF: step to skip SNAPSHOT upgrades
It is not OK to have automatic updates like `1.0.0-SNAPSHOT -> 1.0.1-SNAPSHOT`. Mostly this happens when we had previously update like `1.0.0-RC1 -> 1.0.0-SNAPSHOT`. And current `1.0.0` GA is skipped by Dependabot because `1.0.1-SNAPSHOT` is indeed higher.
1 parent 685ec9b commit 1be06fe

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/spring-merge-dependabot-pr.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,31 @@ jobs:
6161
with:
6262
github-token: ${{ env.GH_TOKEN }}
6363

64+
# Dependabot does not have ability to let us skip from '-SNAPSHOT' updates.
65+
# The problem happens when there is a GA for snapshot we are using right now.
66+
# For example, we have a '1.0.0-SNAPSHOT' after previous update from the '1.0.0-RC1'.
67+
# Now that dependency has gone to '1.0.0' GA, so we would expect an update like '1.0.0-SNAPSHOT -> 1.0.0',
68+
# but Dependabot does '1.0.0-SNAPSHOT -> 1.0.1-SNAPSHOT'.
69+
# This is wrong and causes extra burden in manual changes and commit history.
70+
# Therefore, closing such a PR as invalid.
71+
# See more info in: https://stackoverflow.com/questions/79204574/how-to-make-dependabot-to-not-update-from-snapshot
72+
- name: Close if SNAPSHOT to SNAPSHOT update
73+
if: ${{ endsWith(steps.metadata.outputs.previous-version, '-SNAPSHOT') && endsWith(steps.metadata.outputs.new-version, '-SNAPSHOT') }}
74+
run: |
75+
gh pr edit ${{ github.event.pull_request.number }} --add-label "status: invalid" --remove-milestone --remove-label "${{ inputs.dependenciesLabel }}"
76+
77+
CLOSE_COMMENT="Upgrade from ${{ steps.metadata.outputs.previous-version }} to ${{ steps.metadata.outputs.new-version }} is not allowed"
78+
79+
gh pr close ${{ github.event.pull_request.number }} --comment $CLOSE_COMMENT
80+
81+
gh run cancel ${{ github.run_id }}
82+
echo "::warning title=Cannot merge::$CLOSE_COMMENT"
83+
gh run watch ${{ github.run_id }}
84+
6485
- name: Add a label for development dependencies pull request
6586
if: ${{ steps.metadata.outputs.dependency-group == inputs.developmentGroup || endsWith(steps.metadata.outputs.new-version, '-SNAPSHOT') }}
6687
run: |
67-
gh pr edit ${{ github.event.pull_request.number }} --add-label "${{ inputs.developmentLabel }}"
68-
gh pr edit ${{ github.event.pull_request.number }} --remove-label "${{ inputs.dependenciesLabel }}"
88+
gh pr edit ${{ github.event.pull_request.number }} --add-label "${{ inputs.developmentLabel }}" --remove-label "${{ inputs.dependenciesLabel }}"
6989
7090
- name: Determine auto-merge
7191
id: is-auto-merge

0 commit comments

Comments
 (0)