github-batch-updater

module
v0.0.0-...-84373d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: MIT

README

github batch updater

This application is a rough tool to help with mundane tasks like updating same GH workflow in multiple repos.

It is able to fetch files from multiple repositories, replace some strings and create a PR with the changes. You can also use yq expressions to modify the yaml files.

Installation

go install github.com/kolah/github-batch-updater/cmd/gbu@latest

Usage

In order to interact with the GitHub API, you need to set the GITHUB_PERSONAL_ACCESS_TOKEN env variable with a personal access token. The token should have the repo scope. If you want to interact with GitHub workflows, you need to add the workflow scope.

gbu run script.yml

Example script

create_pr: true
target_branch: batch-test
# source branch is optional, 
# if not provided, it will be the default branch of the repository
# source_branch: main
repositories:
  - name: github-batch-updater
    owner: kolah
  - name: repo2
    owner: kolah
  - name: repo3
    owner: kolah    
files:
  .github/workflows/build_image.yaml:
    - replace:
        replaces:
          - match: "uses: examplecom/pipelines/.github/workflows/someworkflow.yaml@v1.3"
            replace: "uses: examplecom/pipelines/.github/workflows/someworkflow.yaml@v1.6.7"
    - yq:
        expressions:
          - 'del(.jobs.success)'
          - 'del(.jobs.error)'
          - 'del(.jobs.* | select(.uses == "owner/repo/.github/workflows/some_workflow.yaml*"))'
          - ".run-name = \"${{ inputs.revision == 'HEAD' && format('{0}: revision {1}', inputs.environment_name, github.sha) || format('{0}: revision {1}', inputs.environment_name, inputs.revision) }}\""
pull_request:
  title: "Automatic PR batch update"
  body: "This PR updates the build image to the latest version."
  reviewers:
    - "kolah"
  team_reviewers:
    - "my-team"

Directories

Path Synopsis
cmd
gbu command
internal
cli
di

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL