Skip to content

Copies files from any 'key' branch to all other branches. By default, LICENSE, NOTICE and README.md will be copied from the main/master branch to all branches, but it can be configured so you can specify a list of branches, a list of files or branches to exclude from all branches.

License

Notifications You must be signed in to change notification settings

planetoftheweb/copy-to-branches

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy To Branches Action/Shell Script

This action runs a shell script entrypoint.sh file which lets you copy one or more files from a key branch to any other branches in your repo. By default, it copies the following files

  • LICENSE
  • NOTICE
  • README.md
  • CONTRIBUTING.md
  • ./vscode/settings.json
  • .devcontainer/devcontainer.json
  • .github/CODEOWNERS
  • .github/ISSUE_TEMPLATE.MD
  • .github/PULL_REQUEST_TEMPLATE.MD
  • .github/workflows/main.yml

From the main/master branch to all branches on repository.

Running this action

  1. Go to your repo
  2. Click on the Actions tab

Click on Actions Tab

  1. Click on the Set up a workflow yourself link

Set up a workflow yourself link

  1. Use the following script.
name: Copy To Branches
on:
  workflow_dispatch:
jobs:
  copy-to-branches:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Copy To Branches Action
        uses: planetoftheweb/[email protected]
        env:
          key: main
  1. Click the Start commit button

Start Commit Button

  1. Click back on the Actions tab
  2. Click on the Copy To Branches workflow
  3. Click on Run Workflow

The workflow should run automatically, you can monitor it if you want to.

Optional Arguments

By default, the action will try to copy the LICENSE, NOTICE and README.md files from the main branch to all branches, but you can modify the behavior by adding a list of arguments in an env variable.

Example

name: Copy To Branches
on:
  workflow_dispatch:
jobs:
  copy-to-branches:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Copy To Branches Action
        uses: planetoftheweb/copy-to-branches@v1
        env:
          key: main
          exclude: work 99_target
          files: README.md

Using the key branch named main This will copy only the README.md file to all branches, but skip two branches, one named work and one called 99_target.

Key

This is the key branch that you're using as the origin, in other words, the branch you want to copy from. By default, you should include main, but you can ask for a different branch to copy from. Say you wanted to copy files from the branch named 02_03b to all branches. You would use:

env:
  key: 02_03b

Files to copy

By default, the script assumes you want to copy the LICENSE, NOTICE and README.md files. If you want to change this, you can pass along a different list of files to use instead. Use the files keyword and then pass a list of one or more branches separated by spaces.

env:
  files: README.md NOTICE

Branches to Copy

By default, the script assumes you want to copy the files to all the branches in the repo. If you want to copy the files to only certain branches, then you can include this option.

env:
  branches: 02_03b 02_03e 02_04b
  key: main

⚠️ When you add a custom branch list, if you don't include a main or master branch in your list, the script wont run because it won't have a key branch to copy to.

You can easily add a key branch with the key option.

Branches to Exclude

By default, the script will copy the files to all branches. You can exclude one or more branches by creating a list of branches to exclude.

env:
  exclude: target gh-pages

About

Copies files from any 'key' branch to all other branches. By default, LICENSE, NOTICE and README.md will be copied from the main/master branch to all branches, but it can be configured so you can specify a list of branches, a list of files or branches to exclude from all branches.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published