Skip to content

Support GH_ACTIONS_PIN_WORKFLOWS_DIR for non-standard workflow locations - #39

Merged
nodeselector merged 1 commit into
nodeselector/scenario-matrix-live-testingfrom
nodeselector/lab-workflows-dir-override
Jun 12, 2026
Merged

nodeselector merged 1 commit into
nodeselector/scenario-matrix-live-testingfrom
nodeselector/lab-workflows-dir-override

Conversation

@nodeselector

Copy link
Copy Markdown
Collaborator

The CLI hardcodes .github/workflows/ as the scan root for workflow discovery and lockfile placement. In lab and non-standard environments, workflows may live at a different path.

This adds an undocumented GH_ACTIONS_PIN_WORKFLOWS_DIR env var that overrides where the CLI looks for workflow files and the actions.lock lockfile. When unset, behavior is unchanged.

Approach

Three packages touched, all surgical:

  • workflowfile: extracted DiscoverWorkflowsIn(dir) from DiscoverWorkflows() -- the original becomes a thin wrapper passing .github/workflows
  • lockfile: replaced State.repoRoot with State.lockPath (the field was only used for lockfile path computation). Added LoadStateAt(path, meta) constructor for explicit lockfile paths; LoadState wraps it
  • root.go: newRun reads the env var and routes discovery + lockfile I/O through the override dir when set

Testing

  • Added tests for DiscoverWorkflowsIn (happy path + missing dir)
  • All existing tests pass unchanged -- the refactor preserves existing call signatures

Undocumented env var for lab/non-standard environments where workflows
live outside .github/workflows/. When set, workflow discovery and
lockfile I/O (both read and write) use the override directory.

Implementation:
- workflowfile: extract DiscoverWorkflowsIn(dir) from DiscoverWorkflows
- lockfile: replace State.repoRoot with State.lockPath; add LoadStateAt
  for explicit lockfile paths
- root: read env var in newRun, route to DiscoverWorkflowsIn and
  LoadStateAt when set
@nodeselector
nodeselector marked this pull request as ready for review June 12, 2026 13:31
Copilot AI review requested due to automatic review settings June 12, 2026 13:31
@nodeselector
nodeselector merged commit ca83b60 into nodeselector/scenario-matrix-live-testing Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for overriding the GitHub Actions workflows directory (and corresponding actions.lock location) via the GH_ACTIONS_PIN_WORKFLOWS_DIR environment variable, while preserving default behavior when unset.

Changes:

  • Extracted workflowfile.DiscoverWorkflowsIn(dir) for workflow discovery in non-standard directories.
  • Added lockfile.LoadStateAt(path, meta) and refactored state to store an explicit lockfile path.
  • Updated CLI run wiring to route workflow discovery + lockfile I/O through the override directory when provided.
Show a summary per file
File Description
internal/workflowfile/workflowfile.go Adds DiscoverWorkflowsIn(dir) and keeps DiscoverWorkflows() as a wrapper for the default directory.
internal/workflowfile/workflowfile_test.go Adds focused unit tests for DiscoverWorkflowsIn (happy path + missing dir).
internal/lockfile/state.go Refactors state to store lockPath and introduces LoadStateAt to load/save lockfiles at explicit paths.
cmd/gh-actions-pin/root.go Reads GH_ACTIONS_PIN_WORKFLOWS_DIR and uses it to drive workflow discovery and lockfile location.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

internal/workflowfile/workflowfile.go:102

  • The workflow-file filtering logic here (ReadDir + ext check + sort) is effectively duplicated elsewhere (e.g., directory expansion of user-provided paths). To reduce drift risk, consider extracting a small shared helper for listing workflow files in a directory and reusing it across call sites.
// DiscoverWorkflowsIn finds all workflow files (*.yml, *.yaml) in dir.
// Returns nil if the directory doesn't exist.
func DiscoverWorkflowsIn(dir string) ([]string, error) {
	entries, err := os.ReadDir(dir)
	if os.IsNotExist(err) {
		return nil, nil
	}
  • Files reviewed: 4/4 changed files
  • Comments generated: 2

type State struct {
mu sync.Mutex
repoRoot string
lockPath string // full path to actions.lock on disk
Comment on lines +162 to +171
if workflowsDir != "" {
paths, err := workflowfile.DiscoverWorkflowsIn(workflowsDir)
if err != nil {
return nil, err
}
if len(paths) == 0 {
return nil, fmt.Errorf("no workflow files found in %s", workflowsDir)
}
return paths, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants