feat(workflow): add grace-period-minutes input to auto-close workflow - #20
Open
Sachindu-Nethmin wants to merge 5 commits into
Open
Sachindu-Nethmin wants to merge 5 commits into
Sachindu-Nethmin wants to merge 5 commits into
Conversation
Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
The built-in github.token already has issues:write via the workflow permissions block, so prefer it when GH_PAT is absent or misconfigured. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
GH_PAT is set but missing issues:write scope, causing 403 errors. The workflow already declares permissions: issues: write, so the built-in github.token has everything needed to close and label issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
Tests added: - TestGracePeriodFromConfig: validates minutes override > hours config > 72h default precedence in the grace period computation logic - TestGracePeriodMinutesExpiry: validates expiry checks across several minutes-based grace periods and label ages - TestGracePeriodMinutesCLIMapping: validates that CLI flag 0/negative maps to 1, positive values are stored as-is, and absent flag leaves override at 0 - TestRepoFlagParsing: validates owner/repo split for valid and invalid inputs Docs added: - README: new simili auto-close CLI section covering flags, grace period precedence table, simili.yaml config, human activity signals, and workflow_dispatch usage example Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
Sachindu-Nethmin
force-pushed
the
feature/add-grace-period-minutes
branch
from
March 2, 2026 17:40
eb914ae to
e54db43
Compare
inputs.grace_period_minutes is a free-text string that was previously interpolated directly into the shell script body, allowing a crafted value (e.g. "1 $(malicious)") to execute arbitrary commands. Fix: - Assign the input to GRACE_PERIOD_INPUT env var so it never reaches the script body as a template expression. - Validate with ^[0-9]+$ before use; emit a ::warning:: and skip the flag if the value is non-numeric. - Build the argument as a bash array (GRACE_ARGS) so the flag name and value are always passed as two separate quoted tokens, eliminating word-splitting and command-substitution risks. Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds a
grace_period_minutesworkflow dispatch input to the auto-close workflow, allowing users to manually specify a grace period in minutes. Once the grace period expires, issues labelledpotential-duplicateare automatically labelledduplicateand closed.Also fixes a 403 permission error that occurred when
GH_PATwas set but lackedissues:writescope — the workflow now uses the built-ingithub.tokenwhich already has the correct permissions via thepermissionsblock.Type of Change
Related Issues
Relates to #12
Changes Made
grace_period_minutesinput toworkflow_dispatchinauto-close.yml— accepts a number of minutes; leave empty to use the configured default (72 h)--grace-period-minutesflag to the CLI when the input is setsecrets.GH_PATwithgithub.tokento fix 403 errors caused by an under-scoped PAT; the workflowpermissions: issues: writeblock already grants the built-in token everything it needsTesting
go build ./...successfullygo test ./...successfullygo vet ./...successfullyManually triggered the workflow with
grace_period_minutes=1— issues #15 and #16 were successfully labelledduplicateand closed within seconds.Screenshots (if applicable)
Workflow run output:
Checklist
Additional Notes
The
grace_period_minutesinput overrides thegrace_period_hoursvalue in.github/simili.yamlfor that specific run only. The daily scheduled run continues to use the config file value.