Skip to content

apply

The apply command generates compliant workflow files, commits them, and optionally pushes to remote or creates pull requests.

Synopsis

pipelineconductor apply --local <path> --orgs <org> --languages <langs> [flags]

Description

The apply command combines remediation with git operations for batch workflow updates. It:

  • Generates compliant workflow files for non-compliant repositories
  • Creates a git branch for the changes
  • Commits the generated files
  • Optionally pushes to the remote
  • Optionally creates pull requests using the GitHub CLI (gh)

This is useful for rolling out standardized workflows across many repositories in an organization.

Flags

Flag Short Description Default
--local Base path for local filesystem scanning (required)
--languages -l Filter by languages (Go, TypeScript, Crystal) (required)
--ref-repo -r Reference workflow repository (owner/repo) plexusone/.github
--ref-branch Branch in reference repo main
--repo Target specific repository name -
--dry-run Show what would be done without making changes false
--overwrite Overwrite existing workflow files false
--push Push commits to remote after applying false
--create-pr Create pull request after pushing (requires --push and gh CLI) false
--branch Branch name for commits ci/update-workflows
--message -m Commit message auto-generated

Prerequisites

  • Git: Must be installed and repositories must be valid git repos
  • GitHub CLI (gh): Required only if using --create-pr flag

Examples

Generate and Commit (No Push)

Generate workflows and commit them locally:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --languages Go

Generate, Commit, and Push

Push changes to remote after committing:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --languages Go \
  --push

Full Workflow with PR Creation

Generate, commit, push, and create pull requests:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --languages Go \
  --push \
  --create-pr

Target Specific Repository

Apply to a single repository:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --repo my-service \
  --languages Go \
  --push

Custom Branch and Commit Message

Use custom git branch and commit message:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --languages Go \
  --push \
  --branch feature/add-ci-workflows \
  --message "feat: add standardized CI workflows"

Dry Run

Preview what would be done without making any changes:

pipelineconductor apply \
  --local ~/go/src/github.com \
  --orgs myorg \
  --languages Go \
  --push \
  --create-pr \
  --dry-run

Output

The command provides detailed output for each repository:

=== myorg/repo1 ===
  Created: .github/workflows/go-ci.yaml
  Created: .github/workflows/go-lint.yaml
  Created: .github/workflows/go-sast-codeql.yaml
  Committed: ci: add compliant workflows from myorg/.github
  Pushed to: ci/update-workflows
  PR created: https://github.com/myorg/repo1/pull/42

=== myorg/repo2 ===
  Created: .github/workflows/go-ci.yaml
  Committed: ci: add compliant workflows from myorg/.github
  Pushed to: ci/update-workflows
  PR created: https://github.com/myorg/repo2/pull/15

=== Summary ===
Repositories processed: 2
Files created: 4
Committed: 2
Pushed: 2
PRs created: 2

Git Operations

The apply command performs the following git operations:

  1. Create Branch: git checkout -B <branch-name>
  2. Stage Files: git add <workflow-files>
  3. Commit: git commit -m "<message>"
  4. Push (if --push): git push -u origin <branch-name>
  5. Create PR (if --create-pr): gh pr create --title "<message>" --body "..."

Pull Request Template

When --create-pr is used, the generated PR includes:

## Summary

This PR adds compliant CI/CD workflows that use the organization's reusable workflows.

## Changes

- Added go-ci.yaml - Go CI pipeline
- Added go-lint.yaml - Go linting with golangci-lint
- Added go-sast-codeql.yaml - CodeQL security scanning

Generated by [PipelineConductor](https://github.com/plexusone/pipelineconductor)

Error Handling

If an error occurs for a repository, the command continues processing remaining repositories and reports errors in the summary:

=== myorg/repo3 ===
  Created: .github/workflows/go-ci.yaml
  Error: pushing: fatal: remote origin not found

=== Summary ===
Repositories processed: 3
Files created: 5
Committed: 3
Pushed: 2
Errors: 1

Batch Update Script

For more control over the batch update process, you can use the provided shell script:

./scripts/batch-update-workflows.sh ~/go/src/github.com myorg

The script provides an interactive menu:

  1. Generate workflows only (dry-run)
  2. Generate and commit
  3. Generate, commit, and push
  4. Generate, commit, push, and create PRs

See Also

  • check - Check workflow compliance
  • remediate - Generate workflow files without git operations