Skip to content

Commit cc83f74

Browse files
committed
feat: upgraded workflow configs
1 parent 24b84fb commit cc83f74

File tree

3 files changed

+87
-31
lines changed

3 files changed

+87
-31
lines changed

.github/workflows/auto-merge-on-approval.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# • No requested reviewers remaining
1313
# • No "Changes Requested" reviews
1414
# • All required status checks pass:
15-
# - test (1.24.x, ubuntu-latest) (min version)
16-
# - Analyze (go)
15+
# - test (1.24.x, ubuntu-24.04) (min version)
16+
# - test (1.24.x, macos-15) (min version)
17+
# - Analyze (go) (codeql analysis)
18+
# - SonarCloud Code Analysis (sonarcloud)
1719
# • Title must not contain "WIP"
1820
# • PR must not have the "work-in-progress" label
1921
# • PR must not be a draft
@@ -24,7 +26,7 @@ name: auto-merge-on-approval
2426
on:
2527
pull_request:
2628
types:
27-
[opened, synchronize, reopened, ready_for_review, labeled, unlabeled, edited]
29+
[opened, synchronize, reopened, ready_for_review, labeled, unlabeled, edited, review_requested, review_request_removed]
2830
pull_request_review:
2931
types: [submitted]
3032
check_suite:
@@ -114,8 +116,10 @@ jobs:
114116
115117
// Required checks
116118
const requiredChecks = [
117-
'test (1.24.x, ubuntu-latest)',
119+
'test (1.24.x, ubuntu-24.04)',
120+
'test (1.24.x, macos-15)',
118121
'Analyze (go)',
122+
'SonarCloud Code Analysis',
119123
];
120124
const sha = pr.head.sha;
121125
const { data: checks } = await github.rest.checks.listForRef({

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

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ name: dependabot-auto-merge
2020

2121
on:
2222
pull_request_target:
23-
types: [opened, synchronize, reopened, ready_for_review, unlocked, edited]
23+
types: [opened, synchronize, reopened, ready_for_review, unlocked, edited, review_requested, review_request_removed]
2424
pull_request_review:
2525
types: [submitted]
2626
check_suite:
@@ -143,41 +143,76 @@ jobs:
143143
core.setOutput('is_major', !isMinor && !isUnknown);
144144
core.setOutput('is_unknown', isUnknown);
145145
146-
147-
148146
# ---------------------------------------------------------------------
149-
# 4a. Alert on major bump
147+
# 4a. Alert on major bump – only if comment is not already present
150148
# ---------------------------------------------------------------------
151149
- name: Alert on major version bump
152-
if: steps.bump.outputs.is_major == 'true'
150+
if: |
151+
steps.bump.outputs.is_major == 'true' &&
152+
github.event_name == 'pull_request_target' &&
153+
(github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review')
153154
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
154155
with:
155156
github-token: ${{ secrets.GITHUB_TOKEN }}
156157
script: |
157-
await github.rest.issues.createComment({
158+
const issue_number = Number('${{ steps.pr.outputs.number }}');
159+
const commentBody = '⚠️ @galt-tr @mrz1836 – this is a **major** version bump and needs manual review.';
160+
161+
// Check for existing identical comment
162+
const { data: comments } = await github.rest.issues.listComments({
158163
owner: context.repo.owner,
159164
repo: context.repo.repo,
160-
issue_number: Number('${{ steps.pr.outputs.number }}'),
161-
body: '⚠️ @icellan – this is a **major** version bump and needs manual review.'
165+
issue_number,
166+
per_page: 100
162167
});
163168
169+
if (comments.some(c => c.body.trim() === commentBody.trim())) {
170+
core.info('Major bump alert comment already exists – skipping.');
171+
} else {
172+
await github.rest.issues.createComment({
173+
owner: context.repo.owner,
174+
repo: context.repo.repo,
175+
issue_number,
176+
body: commentBody
177+
});
178+
}
179+
164180
165181
# ---------------------------------------------------------------------
166182
# 4b. Alert when a version couldn’t be parsed (commit SHA → SHA)
183+
# – only if comment not already present
167184
# ---------------------------------------------------------------------
168185
- name: Alert on undetected version bump
169-
if: steps.bump.outputs.is_unknown == 'true'
186+
if: |
187+
steps.bump.outputs.is_unknown == 'true' &&
188+
github.event_name == 'pull_request_target' &&
189+
(github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'ready_for_review')
170190
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
171191
with:
172192
github-token: ${{ secrets.GITHUB_TOKEN }}
173193
script: |
174-
await github.rest.issues.createComment({
194+
const issue_number = Number('${{ steps.pr.outputs.number }}');
195+
const commentBody = '⚠️ @galt-tr @mrz1836 – Dependabot could not determine version semantics (SHA → SHA). Please review manually.';
196+
197+
// Check for existing identical comment
198+
const { data: comments } = await github.rest.issues.listComments({
175199
owner: context.repo.owner,
176200
repo: context.repo.repo,
177-
issue_number: Number('${{ steps.pr.outputs.number }}'),
178-
body: '⚠️ @icellan – Dependabot could not determine version semantics (SHA → SHA). Please review manually.'
201+
issue_number,
202+
per_page: 100
179203
});
180204
205+
if (comments.some(c => c.body.trim() === commentBody.trim())) {
206+
core.info('Unknown bump alert comment already exists – skipping.');
207+
} else {
208+
await github.rest.issues.createComment({
209+
owner: context.repo.owner,
210+
repo: context.repo.repo,
211+
issue_number,
212+
body: commentBody
213+
});
214+
}
215+
181216
182217
# -----------------------------------------------------------------------
183218
# 5. Auto-approve minor / patch bumps

.github/workflows/pull-request-management.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
const DEFAULT_ASSIGNEE = 'icellan'; // <-- change if needed
5050
5151
// Helpers -------------------------------------------------------
52-
const pr = context.payload.pull_request;
53-
const owner = context.repo.owner;
54-
const repo = context.repo.repo;
52+
const pr = context.payload.pull_request;
53+
const owner = context.repo.owner;
54+
const repo = context.repo.repo;
5555
const issue_number = pr.number;
5656
5757
const isFromFork = pr.head.repo.owner.login !== owner;
@@ -129,29 +129,46 @@ jobs:
129129
// 3. Welcome new contributors with a friendly comment
130130
// ──────────────────────────────────────────────────────────────
131131
try {
132-
const author = pr.user.login;
133-
const knownBots = ['dependabot[bot]', 'mergify[bot]', 'copilot[bot]', 'Copilot', DEFAULT_ASSIGNEE];
134-
const shouldWelcome = !knownBots.includes(author) && context.payload.action === 'opened';
132+
const author = pr.user.login;
133+
const isFirstTime = ['FIRST_TIMER', 'FIRST_TIME_CONTRIBUTOR'].includes(pr.author_association);
134+
135+
const knownBots = [
136+
'dependabot[bot]',
137+
'mergify[bot]',
138+
'copilot[bot]',
139+
'Copilot',
140+
DEFAULT_ASSIGNEE,
141+
];
142+
143+
const shouldWelcome =
144+
isFirstTime &&
145+
!knownBots.includes(author) &&
146+
context.payload.action === 'opened';
135147
136148
if (shouldWelcome) {
137149
if (isFromFork) {
138150
console.warn('Skipping welcome comment: PR is from fork and token lacks permission to comment.');
139151
} else {
140-
const welcomeBody = `\n👋 **Welcome, @${author}!**\n\nThanks for opening your first pull request in **${owner}/${repo}**. \nA maintainer will review your contribution shortly.\n\n_If you have any questions feel free to reach out!_`;
152+
const body = `👋 **Welcome, @${author}!**
153+
154+
Thanks for opening your first pull request in **${owner}/${repo}**.
155+
A maintainer will review your contribution shortly.
156+
157+
_If you have any questions feel free to reach out!_`;
141158
142159
await github.rest.issues.createComment({
143-
owner,
144-
repo,
145-
issue_number,
146-
body: welcomeBody,
160+
owner,
161+
repo,
162+
issue_number,
163+
body,
147164
});
148165
console.log('Posted welcome comment.');
149-
}
150166
}
151-
} catch (error) {
167+
}
168+
} catch (error) {
152169
if (isIntegrationError(error) && isFromFork) {
153-
console.warn('Skipping welcome comment due to integration permission limits on fork PR.');
170+
console.warn('Skipping welcome comment due to integration permission limits on fork PR.');
154171
} else {
155-
core.setFailed(`Posting welcome comment failed: ${error.message}`);
172+
core.setFailed(`Posting welcome comment failed: ${error.message}`);
156173
}
157174
}

0 commit comments

Comments
 (0)