Coder Social home page Coder Social logo

bjerkio / kopier Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3.07 MB

Github Actions to help share information across many repositories

License: Apache License 2.0

JavaScript 1.85% TypeScript 96.84% Handlebars 1.31%
kopier github actions library package

kopier's Introduction

Bjerk's Kopier Github Action

Language grade: JavaScript codecov Maintainability

Kopier

Kopier is a Github Action made to generate/copy files across multiple repositories. The software is inspired initially by Copybara and a continuation of Tabetalt's Kopier.

Features

  • Copy files to multiple repositories.
  • Generate files (such as Github Actions files) with a Handlebarsjs.
  • When templates or files are changed, you can create a pull request for each repository.

Use cases

Kopier was made to make it easier to handle repeatable tasks when working with a multi-repository setup. In our case, we work with many microservices separated in multiple repositories. We want to make sure we are running the same Github Actions workflow for each, but there are differences, like the name etc.

Example Usage

jobs:
  build:
    steps:
      - uses: bjerkio/kopier@main
        with:
          query: 'org:bjerkio'

Input

token

Github Token must be a personal one, not {{ secret.GITHUB_TOKEN }}! We recommend using a service account GitHub profile, like @bjerk-bot

query

Search for repositories you want to query. Learn how to search for repositories on Github Docs.

Note: You cannot combine query with repos.

repos

List of repositories to add files to.

Example:

steps:
  - uses: bjerkio/kopier@main
    with:
      repos: |
        bjerkio/kopier
        bjerkio/oidc-react

base-path

Base path for in the repositories, e.g. .github/workflows.

Default is templates/.

commit-message

Commit message.

Default is chore(kopier): {{commit.subject}}.

title

Pull Request title.

Default is chore(kopier): {{commit.subject}}.

body

Pull Request body.

Default is found in src/pr-message.ts.

head

A branch name for updates.

Default is kopier-{{ commit sha }}.

base

Base-branch is where the pull request is opened.

Defaults to default branch

Documentation

Apart from this README, you can find details and examples of using the SDK in the following places:

Similar tools

Contribute

Feel free to open issues and pull requests. We appreciate all the help we can get! ๐ŸŽ‰

kopier's People

Contributors

renovate[bot] avatar simenandre avatar

Watchers

 avatar  avatar

kopier's Issues

Consider only constructing configuration once

We are currently using githubActionConfig (soon makeConfig) on multiple functions to get the relevant configuration values for each. We should probably not construct run this function like this, and only construct it once.

We should consider refactoring. I'd like to see a way to a more easily tested structure.

Sanitize commit messages

fork of #1

Example (we'll call this repository micro)

  • chore(kopier): fix: huge problem (#2) in micro.

There are two issues with this. First of all; #2 references issue 2 in micro. Which is bad.

Tracking this change.

Error: TypeError: Cannot read property 'filter' of null

Workflow this happends on:

on:
  push:
    branches: [dockerx]

jobs:
  push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: bjerkio/kopier@main
        with:
          repos: |
            indivorg/service-user
          github-token: ${{ secrets.GH_PRIVATE_TOKEN }}

Push to existing branch / PR

In v2 we've started using octokit-plugin-create-pull-request, which seems like a winner for Kopier!

However, I keep getting the error HttpError: Reference already exists. AFAIK, we can add a try-catch when creating a pull request and if it fails with already existing, we update the ref on the branch instead.

References

Configure to use named branch (update branch if exists)

If you use Dependabot to keep your Github Actions workflows updated, you probably get more than one pull request when doing maintenance.

This can in some cases produce more than one pull request on the source repositories, which we probably don't want?

Dry-run functionality

We should be able to dry run, potentially preview the transformed files somehow.

Could be used to improve pull request flow when using kopier.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/node to ~15.14.0
  • chore(deps): update dependency eslint to v8
  • chore(deps): update dependency eslint-plugin-jest to v27
  • chore(deps): update dependency faker to v6 (faker, @types/faker)
  • chore(deps): update dependency husky to v8
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency rimraf to v5
  • chore(deps): update dependency typescript to v5
  • chore(deps): update dependency webpack-cli to v5
  • chore(deps): update googlecloudplatform/release-please-action action to v3
  • chore(deps): update jest monorepo to v29 (major) (@types/jest, jest, ts-jest)
  • chore(deps): update mshick/add-pr-comment action to v2
  • chore(deps): update node.js to v18 (node, @types/node)
  • chore(deps): update typescript-eslint monorepo to v6 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • fix(deps): update dependency octokit-plugin-create-pull-request to v5
  • fix(deps): update dependency uuid to v9
  • fix(deps): update octokit monorepo (major) (@octokit/action, @octokit/core)
  • chore(deps): lock file maintenance
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/e2e.yaml
  • actions/checkout v1
.github/workflows/pull_request.yml
  • actions/checkout v2
  • dorny/paths-filter v2
  • mshick/add-pr-comment v1
  • actions/checkout v2
  • actions/cache v3
  • dorny/paths-filter v2
.github/workflows/push.yml
  • actions/checkout v2
  • actions/cache v3
.github/workflows/workflow.yml
  • actions/checkout v2
  • stefanzweifel/git-auto-commit-action v4
  • GoogleCloudPlatform/release-please-action v2
npm
package.json
  • @actions/core ^1.3.0
  • @actions/exec ^1.0.4
  • @actions/github ^5.0.0
  • @actions/glob ^0.1.2
  • @octokit/action ^3.10.0
  • @octokit/core ^3.2.5
  • @vercel/ncc ^0.36.0
  • handlebars ^4.7.7
  • mime-types ^2.1.30
  • octokit-plugin-create-pull-request ^3.9.3
  • runtypes ^6.3.0
  • tslib ~2.2.0
  • uuid ^8.3.2
  • @types/faker ^5.5.5
  • @types/flat ^5.0.1
  • @types/jest ~26.0.23
  • @types/mime-types ^2.1.0
  • @types/node ~15.6.0
  • @typescript-eslint/eslint-plugin ~4.24.0
  • @typescript-eslint/parser ~4.24.0
  • eslint ~7.27.0
  • eslint-config-prettier ~8.3.0
  • eslint-plugin-jest ~24.3.6
  • faker ^5.5.3
  • husky ^6.0.0
  • jest ~26.6.3
  • nock ^13.0.11
  • prettier ~2.8.0
  • rimraf ~3.0.2
  • ts-jest ~26.5.6
  • ts-loader ^9.2.2
  • tsutils ~3.21.0
  • typescript ~4.2.4
  • webpack ^5.37.1
  • webpack-cli ^4.7.0
  • node >= 14.16
  • node 14.16.0
  • yarn 1.22.10

  • Check this box to trigger a request for Renovate to run again on this repository

Transform issue tags / title

In our case, we have a repository (workflows) which contains all Github Actions workflows for many of our microservice repository.

We utilize a Pull Request flow in our workflows repository (like we do for them all), and we often reference issues in workflows repository in the pull request.

Example:

  1. We create an issue in workflows, let's say its issue #1.
  2. We create a pull request, the pull request title is: fix: huge problem. PR is named pr #2
  3. We squash this PR (commit message is: fix: huge problem (#2).

Since Kopier creates pull requests in all defined repositories in workflows. We will receive many pull requests as such:

Example (we'll call this repository micro)

  • chore(kopier): fix: huge problem (#2) in micro.

There are two issues with this. First of all; #2 references issue 2 in micro. Which is bad.
Secondly, we have issues with not following conventional commits (chore: fix:). IMO, the title for the pull request in micro should be named:

fix(kopier): huge problem (myorg/workflows#2)

Refactor to use Github API

It might be useful to use the Github API instead of git. Feels like it would end up less code ๐Ÿคทโ€โ™‚๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.