Skip to content

Commit 22dd02e

Browse files
committed
fix: unknown version mod
1 parent 9e0f697 commit 22dd02e

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

.github/workflows/dependabot-auto-merge.yml

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ jobs:
8686
core.setOutput('actor', pr.user.login);
8787
core.setOutput('title', pr.title.replace(/\n/g, ' '));
8888
89+
90+
# -----------------------------------------------------------------------
91+
# 1a. Exit when no PR was found
92+
# -----------------------------------------------------------------------
8993
- name: Exit when no PR found
9094
if: steps.pr.outputs.found != 'true'
9195
run: echo "PR not found – exiting."
@@ -105,30 +109,45 @@ jobs:
105109
core.setOutput('allowed', allowed);
106110
if (!allowed) core.info(`PR opened by ${actor} – skipping automerge.`);
107111
112+
113+
# -----------------------------------------------------------------------
114+
# 2a. Exit when PR was not opened by Dependabot
115+
# -----------------------------------------------------------------------
108116
- name: Exit for non-Dependabot PR
109117
if: steps.author.outputs.allowed != 'true'
110118
run: echo "Not a Dependabot PR – exiting."
111119

112-
# -----------------------------------------------------------------------
113-
# 3. Detect major vs. minor/patch bump
114-
# -----------------------------------------------------------------------
120+
# ---------------------------------------------------------------------
121+
# 3. Detect minor / major / unknown bump
122+
# ---------------------------------------------------------------------
115123
- name: Check version bump
116124
id: bump
117125
if: steps.author.outputs.allowed == 'true'
118126
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
119127
with:
120128
script: |
121129
const title = '${{ steps.pr.outputs.title }}';
130+
122131
// Matches “from 1.2.3 to 1.3.0”, “from v4 to v4.0.1”, etc.
123132
const match = title.match(/from\s+v?(\d+)(?:\.\d+)*\s+to\s+v?(\d+)/i);
124-
const isMinor = !!(match && match[1] === match[2]);
125-
core.setOutput('is_minor', isMinor);
126-
core.setOutput('is_major', !isMinor);
133+
let isMinor = false;
134+
let isUnknown = false;
127135
136+
if (!match) {
137+
isUnknown = true; // SHA bumps or unparsable versions
138+
} else {
139+
isMinor = match[1] === match[2];
140+
}
128141
129-
# -----------------------------------------------------------------------
130-
# 4. Alert on major bump
131-
# -----------------------------------------------------------------------
142+
core.setOutput('is_minor', isMinor);
143+
core.setOutput('is_major', !isMinor && !isUnknown);
144+
core.setOutput('is_unknown', isUnknown);
145+
146+
147+
148+
# ---------------------------------------------------------------------
149+
# 4a. Alert on major bump
150+
# ---------------------------------------------------------------------
132151
- name: Alert on major version bump
133152
if: steps.bump.outputs.is_major == 'true'
134153
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -143,6 +162,23 @@ jobs:
143162
});
144163
145164
165+
# ---------------------------------------------------------------------
166+
# 4b. Alert when a version couldn’t be parsed (commit SHA → SHA)
167+
# ---------------------------------------------------------------------
168+
- name: Alert on undetected version bump
169+
if: steps.bump.outputs.is_unknown == 'true'
170+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
171+
with:
172+
github-token: ${{ secrets.GITHUB_TOKEN }}
173+
script: |
174+
await github.rest.issues.createComment({
175+
owner: context.repo.owner,
176+
repo: context.repo.repo,
177+
issue_number: Number('${{ steps.pr.outputs.number }}'),
178+
body: '⚠️ @mrz1836 – Dependabot could not determine version semantics (SHA → SHA). Please review manually.'
179+
});
180+
181+
146182
# -----------------------------------------------------------------------
147183
# 5. Auto-approve minor / patch bumps
148184
# -----------------------------------------------------------------------
@@ -171,6 +207,7 @@ jobs:
171207
});
172208
173209
210+
174211
# -----------------------------------------------------------------------
175212
# 7. Auto-merge when checks are green
176213
# -----------------------------------------------------------------------

0 commit comments

Comments
 (0)