86
86
core.setOutput('actor', pr.user.login);
87
87
core.setOutput('title', pr.title.replace(/\n/g, ' '));
88
88
89
+
90
+ # -----------------------------------------------------------------------
91
+ # 1a. Exit when no PR was found
92
+ # -----------------------------------------------------------------------
89
93
- name : Exit when no PR found
90
94
if : steps.pr.outputs.found != 'true'
91
95
run : echo "PR not found – exiting."
@@ -105,30 +109,45 @@ jobs:
105
109
core.setOutput('allowed', allowed);
106
110
if (!allowed) core.info(`PR opened by ${actor} – skipping automerge.`);
107
111
112
+
113
+ # -----------------------------------------------------------------------
114
+ # 2a. Exit when PR was not opened by Dependabot
115
+ # -----------------------------------------------------------------------
108
116
- name : Exit for non-Dependabot PR
109
117
if : steps.author.outputs.allowed != 'true'
110
118
run : echo "Not a Dependabot PR – exiting."
111
119
112
- # -----------------------------------------------------------------------
113
- # 3. Detect major vs. minor/patch bump
114
- # -----------------------------------------------------------------------
120
+ # ---------------------------------------------------------------------
121
+ # 3. Detect minor / major / unknown bump
122
+ # ---------------------------------------------------------------------
115
123
- name : Check version bump
116
124
id : bump
117
125
if : steps.author.outputs.allowed == 'true'
118
126
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
119
127
with :
120
128
script : |
121
129
const title = '${{ steps.pr.outputs.title }}';
130
+
122
131
// Matches “from 1.2.3 to 1.3.0”, “from v4 to v4.0.1”, etc.
123
132
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;
127
135
136
+ if (!match) {
137
+ isUnknown = true; // SHA bumps or unparsable versions
138
+ } else {
139
+ isMinor = match[1] === match[2];
140
+ }
128
141
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
+ # ---------------------------------------------------------------------
132
151
- name : Alert on major version bump
133
152
if : steps.bump.outputs.is_major == 'true'
134
153
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -143,6 +162,23 @@ jobs:
143
162
});
144
163
145
164
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
+
146
182
# -----------------------------------------------------------------------
147
183
# 5. Auto-approve minor / patch bumps
148
184
# -----------------------------------------------------------------------
@@ -171,6 +207,7 @@ jobs:
171
207
});
172
208
173
209
210
+
174
211
# -----------------------------------------------------------------------
175
212
# 7. Auto-merge when checks are green
176
213
# -----------------------------------------------------------------------
0 commit comments