-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add major decision auto-approval workflow #4162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ranshid
merged 2 commits into
valkey-io:unstable
from
sarthakaggarwal97:major-decision-auto-approve
Jul 21, 2026
+123
−0
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: Auto-approve Pending Major Decisions | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 3 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: major-decision-auto-approve | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| approve: | ||
| if: github.repository == 'valkey-io/valkey' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Approve major decisions pending for two weeks | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const AUTO_LABEL = 'major-decision-pending-auto-approve'; | ||
| const cutoff = Date.now() - 14 * 24 * 60 * 60 * 1000; | ||
| const { owner, repo } = context.repo; | ||
|
|
||
| const getLatestAutoLabelTime = async issueNumber => { | ||
| const events = await github.paginate(github.rest.issues.listEvents, { | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| let labeledAt = 0; | ||
| for (const event of events) { | ||
| if (event.event === 'labeled' && event.label?.name === AUTO_LABEL) { | ||
| labeledAt = Math.max(labeledAt, Date.parse(event.created_at)); | ||
| } | ||
| } | ||
| return labeledAt; | ||
| }; | ||
|
|
||
| const candidates = await github.paginate(github.rest.issues.listForRepo, { | ||
| owner, | ||
| repo, | ||
| state: 'open', | ||
| labels: AUTO_LABEL, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| for (const candidate of candidates) { | ||
| const labeledAt = await getLatestAutoLabelTime(candidate.number); | ||
| if (!labeledAt || labeledAt > cutoff) { | ||
| core.info(`#${candidate.number} is not eligible for auto-approval yet.`); | ||
| continue; | ||
| } | ||
|
|
||
| // Re-read the labels in case they changed while this workflow was running. | ||
| const { data: issue } = await github.rest.issues.get({ | ||
| owner, | ||
| repo, | ||
| issue_number: candidate.number, | ||
| }); | ||
| const labels = new Set(issue.labels.map(label => label.name ?? label)); | ||
| if (!labels.has(AUTO_LABEL)) { | ||
|
sarthakaggarwal97 marked this conversation as resolved.
Outdated
|
||
| core.info(`#${candidate.number} no longer has ${AUTO_LABEL}; skipping it.`); | ||
| continue; | ||
| } | ||
|
|
||
| const currentLabeledAt = await getLatestAutoLabelTime(candidate.number); | ||
| if (!currentLabeledAt || currentLabeledAt > cutoff) { | ||
| core.info(`#${candidate.number} is not eligible after re-checking ${AUTO_LABEL}.`); | ||
| continue; | ||
| } | ||
|
|
||
| await github.rest.issues.addLabels({ | ||
| owner, | ||
| repo, | ||
| issue_number: candidate.number, | ||
| labels: ['major-decision-approved'], | ||
| }); | ||
|
|
||
| const removeLabel = async label => { | ||
| if (!labels.has(label)) return; | ||
| try { | ||
| await github.rest.issues.removeLabel({ | ||
| owner, | ||
| repo, | ||
| issue_number: candidate.number, | ||
| name: label, | ||
| }); | ||
| } catch (error) { | ||
| if (error.status !== 404) throw error; | ||
| } | ||
| }; | ||
|
|
||
| await removeLabel('major-decision-pending'); | ||
| await removeLabel(AUTO_LABEL); | ||
|
|
||
| core.info(`Approved major decision for #${candidate.number}.`); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.