Skip to content

Commit fa00f61

Browse files
authored
ci(workflows): switch to shared force merge workflow (#10)
ci(workflows): introduce shared force merge workflow
1 parent 3b4d5a6 commit fa00f61

1 file changed

Lines changed: 2 additions & 117 deletions

File tree

.github/workflows/force-merge.yml

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -10,121 +10,6 @@ permissions:
1010
pull-requests: write
1111
issues: write
1212

13-
env:
14-
quorum: 3
15-
1613
jobs:
17-
force_merge:
18-
# This job only runs for pull request comments
19-
if: ${{ github.event.issue.pull_request }}
20-
runs-on: ubuntu-latest
21-
22-
steps:
23-
- name: Check pull request
24-
id: should-run
25-
uses: actions/github-script@v7
26-
with:
27-
script: |
28-
const issue = await github.rest.issues.get({
29-
issue_number: context.issue.number,
30-
owner: context.repo.owner,
31-
repo: context.repo.repo
32-
})
33-
34-
const isClosed = issue.data.closed_at != null
35-
const isDraft = issue.data.draft
36-
37-
return !isClosed && !isDraft
38-
39-
- name: Count votes
40-
id: count-votes
41-
if: ${{ steps.should-run.outputs.result == 'true' }}
42-
uses: actions/github-script@v7
43-
with:
44-
script: |
45-
const comments = await github.rest.issues.listComments({
46-
issue_number: context.issue.number,
47-
owner: context.repo.owner,
48-
repo: context.repo.repo
49-
})
50-
51-
// Check if debug mode is enabled by any comment containing "/debug-force-merge"
52-
const debugEnabled = comments.data.some(comment =>
53-
comment.body && comment.body.includes('/debug-force-merge')
54-
);
55-
56-
// Debug: Print all commenters and their associations (only if debug enabled)
57-
if (debugEnabled) {
58-
console.log("=== All Comments Debug ===");
59-
for(const comment of comments.data) {
60-
console.log(`User: ${comment.user.login}`);
61-
console.log(`Association: ${comment.author_association}`);
62-
console.log(`Has voting rights: ${comment.author_association === 'MEMBER' || comment.author_association === 'OWNER'}`);
63-
console.log(`Has casted vote: ${comment.body && comment.body.trim() === '/force-merge'}`);
64-
console.log("---");
65-
}
66-
}
67-
68-
const votes = new Map();
69-
for(const comment of comments.data) {
70-
const hasVotingRights = comment.author_association === 'MEMBER' || comment.author_association === 'OWNER'
71-
const hasCastedVote = comment.body && comment.body.trim() === '/force-merge'
72-
73-
if(hasVotingRights && hasCastedVote) {
74-
votes.set(comment.user.login, comment.author_association);
75-
}
76-
}
77-
78-
// Display voters and role
79-
console.table(votes)
80-
81-
return votes.size
82-
83-
- name: Set lables
84-
if: ${{ steps.should-run.outputs.result == 'true' }}
85-
uses: actions/github-script@v7
86-
with:
87-
script: |
88-
const labels = await github.rest.issues.listLabelsOnIssue({
89-
issue_number: context.issue.number,
90-
owner: context.repo.owner,
91-
repo: context.repo.repo
92-
})
93-
const labelsToAdd = []
94-
for(const label of labels.data) {
95-
if(!label.name.startsWith('force-merge-votes-')) {
96-
labelsToAdd.push(label.name)
97-
}
98-
}
99-
100-
const votes = ${{ steps.count-votes.outputs.result }}
101-
if(votes >= 1 && votes < ${{env.quorum}}) {
102-
labelsToAdd.push("force-merge-votes-" + votes)
103-
}
104-
105-
const result = github.rest.issues.setLabels({
106-
issue_number: context.issue.number,
107-
owner: context.repo.owner,
108-
repo: context.repo.repo,
109-
labels: labelsToAdd
110-
})
111-
112-
- name: Perform merge
113-
if: ${{ (steps.should-run.outputs.result == 'true') && (steps.count-votes.outputs.result >= env.quorum) }}
114-
uses: actions/github-script@v7
115-
with:
116-
github-token: ${{ secrets.KURA_BOT_GITHUB_TOKEN }}
117-
script: |
118-
github.rest.issues.addLabels({
119-
issue_number: context.issue.number,
120-
owner: context.repo.owner,
121-
repo: context.repo.repo,
122-
labels: ['force-merged']
123-
})
124-
125-
await github.rest.pulls.merge({
126-
pull_number: context.issue.number,
127-
owner: context.repo.owner,
128-
repo: context.repo.repo,
129-
merge_method: "squash"
130-
});
14+
call-workflow-in-public-repo:
15+
uses: eclipse-kura/.github/.github/workflows/_shared-force-merge.yml@main

0 commit comments

Comments
 (0)