Repository navigation
feat(drift-detection): add scheduled example with sticky issue - #5
Merged
Merged
Conversation
igorjs
force-pushed
the
feat/enterprise-hardening-s4-oidc
branch
2 times, most recently
from
September 7, 2026 04:18
73005b2 to
208fdf5
Compare
Adds examples/drift-detection.yml, a scheduled (daily cron plus workflow_dispatch) consumer workflow that calls the action with no command override, relying on its existing plan-by-default behavior for non-push events. When the plan reports changes, a bash step opens or updates a single sticky Issue, scoped by the drift-detection label (bounded search) and confirmed by a marker in the body. Adds tests/drift-issue.sh, which extracts the real run: block from that step via yaml.safe_load (same technique ci.yml's self-lint job uses for action.yml) and executes it under a stubbed gh CLI on PATH that logs every invocation and returns canned issue-list responses. Covers the no-existing-issue (POST) and existing-issue (PATCH) scenarios, plus a direct grep check that the step is gated on has-changes == 'true'. Verified empirically against the live GitHub API (scratch private repo, deleted after) rather than assumed: the -F "labels[]=..." array syntax works for issue creation, and GitHub auto-creates a label that does not exist yet when an issue is created with it, so no separate label-provisioning step is needed. Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
igorjs
force-pushed
the
feat/enterprise-hardening-s5-drift-detection
branch
from
September 7, 2026 04:19
e2389b8 to
b01dd29
Compare
igorjs
changed the base branch from
feat/enterprise-hardening-s4-oidc
to
main
September 7, 2026 04:19
- Guard the drift-issue search against a null response body. - Capture -F/-f field values in the gh stub, not just verb+path. - Assert the created issue carries the drift-detection label. - Note the drift-issue step still inherits backend credentials via GITHUB_ENV persistence, harmless today but worth flagging. - Scope Scenario 3's if: check to the whole step block via awk instead of a brittle adjacent-line grep. Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
igorjs
force-pushed
the
feat/enterprise-hardening-s5-drift-detection
branch
from
September 7, 2026 04:27
b01dd29 to
2abfd46
Compare
igorjs
marked this pull request as ready for review
September 7, 2026 04:27
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.
Summary
There's no way to catch changes that land outside this pipeline (a console edit, a manual
terraform apply) until someone runs a plan by hand. This adds a scheduled example that runs a daily plan and reports drift through a single sticky Issue instead of paging anyone or filing a new Issue every day.What Changed
examples/drift-detection.yml:on: scheduleplusworkflow_dispatchfor manual runs, calling the action with nocommand:override. The safer default from segment 1 already resolves toplanfor any nonpushevent, so a scheduled run never applies anything on its own.has-changescomes back'true', a follow-up step opens or updates one Issue labeleddrift-detection. It searches only issues with that label for a hidden marker in the body, so the lookup stays bounded instead of scanning every open issue. Same sticky pattern the PR comment step already uses, just for Issues instead of comments.jq'sstartswithblow up and aborted the step underpipefail. The body lookup now falls back to an empty string before the check. Covered by a new test scenario and mutation-tested.tests/drift-issue.shtest harness. It extracts the realrun:block straight out of the workflow file with PyYAML (same technique the self-lint check already uses foraction.yml), so the test exercises the actual script, not a hand-copied stand-in. Runs it against a stubbedghCLI across three scenarios: no existing issue, an existing issue to update, and the null-body case.tests/drift-issue.shwas written but not wired into CI at first. Caught that in the same review pass and added it toci.yml's test job, right aftertests/action-logic.sh, with thepyyamlinstall step it needs.Notes for reviewers
feat/enterprise-hardening-s4-oidc(PR feat(s3): add OIDC auth via aws-role-arn, unify credentials #4), notmain. It's segment 5 of the enterprise-hardening stack and depends on the OIDC work landing first.