Skip to content

Commit a2a11ad

Browse files
committed
Fix Dependabot logic for SNAPSHOTs
The Dependabot has a logic which we find as wrong. It updates from the current `M/RC/SNAPSHOT` not to the GA of that version, but to the next version's `SNAPSHOT` * Fix `spring-merge-dependabot-pr.yml` to compare `new-version` and `previous-version` metadata without suffixes. For example, compare the current ` 1.0.0-RC1 ` with a new `1.0.1-SNAPSHOT`. This means there is a GA we would expect an update to, but somehow Dependabot skips that for us. * Close its PRs in this case. Only allow update to a new `SNAPSHOT` if `new-version` and `previous-version` version bases are equal
1 parent 5a78bc6 commit a2a11ad

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,36 @@ jobs:
6161
with:
6262
github-token: ${{ env.GH_TOKEN }}
6363

64-
# Dependabot does not have ability to let us skip from '-SNAPSHOT' updates.
64+
# Dependabot does not have the ability to let us skip from '-SNAPSHOT' updates.
6565
# 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'.
66+
# For example, we have a '1.0.0-SNAPSHOT' after the previous update from the '1.0.0-RC1'.
6767
# Now that dependency has gone to '1.0.0' GA, so we would expect an update like '1.0.0-SNAPSHOT -> 1.0.0',
6868
# but Dependabot does '1.0.0-SNAPSHOT -> 1.0.1-SNAPSHOT'.
69+
# Another example, if we have a '1.0.0-RC1' but Dependabot does upgrade to '1.0.1-SNAPSHOT' instead of '1.0.0'.
6970
# This is wrong and causes extra burden in manual changes and commit history.
7071
# Therefore, closing such a PR as invalid.
7172
# 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') }}
73+
- name: Close if to SNAPSHOT update skipping GA
74+
if: endsWith(steps.metadata.outputs.new-version, '-SNAPSHOT')
7475
run: |
75-
gh pr edit ${{ github.event.pull_request.number }} --add-label "status: invalid" --remove-milestone --remove-label "${{ inputs.dependenciesLabel }}"
76+
NEW_VERSION="${{ steps.metadata.outputs.new-version }}"
77+
NEW_VERSION=${NEW_VERSION/-SNAPSHOT}
7678
77-
CLOSE_COMMENT="Upgrade from ${{ steps.metadata.outputs.previous-version }} to ${{ steps.metadata.outputs.new-version }} is not allowed"
79+
PREVIOUS_VERSION="${{ steps.metadata.outputs.previous-version }}"
80+
PREVIOUS_VERSION=${PREVIOUS_VERSION/-*}
7881
79-
gh pr close ${{ github.event.pull_request.number }} --comment "$CLOSE_COMMENT"
82+
if [ $NEW_VERSION != $PREVIOUS_VERSION ]
83+
then
84+
gh pr edit ${{ github.event.pull_request.number }} --add-label "status: invalid" --remove-milestone --remove-label "${{ inputs.dependenciesLabel }}"
85+
86+
CLOSE_COMMENT="Upgrade from ${{ steps.metadata.outputs.previous-version }} to ${{ steps.metadata.outputs.new-version }} is not allowed"
87+
88+
gh pr close ${{ github.event.pull_request.number }} --comment "$CLOSE_COMMENT"
8089
81-
gh run cancel ${{ github.run_id }}
82-
echo "::warning title=Cannot merge::$CLOSE_COMMENT"
83-
gh run watch ${{ github.run_id }}
90+
gh run cancel ${{ github.run_id }}
91+
echo "::warning title=Cannot merge::$CLOSE_COMMENT"
92+
gh run watch ${{ github.run_id }}
93+
fi
8494
8595
- name: Add a label for development dependencies pull request
8696
if: ${{ steps.metadata.outputs.dependency-group == inputs.developmentGroup || endsWith(steps.metadata.outputs.new-version, '-SNAPSHOT') }}

0 commit comments

Comments
 (0)