Skip to content
copy

GitHub Action

In Sync Action

1.2.0 Latest version

In Sync Action

copy

In Sync Action

Keep files in-sync between repositories

Installation

Copy and paste the following snippet into your .yml file.

              

- name: In Sync Action

uses: solubris/insync@1.2.0

Learn more about this action in solubris/insync

Choose a version

CI workflow version

Sync files

Helps keep files in sync between repositories by pushing changes in a src repo to a dest repo.

NOTE: repo's don't have to be forks, can be completely disparate

Example action

Create the action in the source project:

.github/workflows/main.yml

With the contents:

on:
  push:
    branches: [master]

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - id: sync
        uses: solubris/insync@1.2.0
        with:
          repositories: the-dst-repo
          token: ${{ secrets.TOKEN }}
          files: |
            .gitignore
            .editorconfig

NOTE: requires the token used to access the dest repo to be saved in the secrets in the source repo Alternatively, the secret could be saved at the organisation level

Future enhancements

  • user/email of source commit could be used for pushing to the dest repo - done
  • delete branch if job failed
    • only do this if the branch wasn't already there
  • dont overwrite if dst file is newer
    • this might add undue complexity
  • test adding new files - done
  • test adding files in subdir - done
  • collating changes - multiple changes can be collated to an existing branch - done
    • what about the pr description, should subsequent changes update the pr description?
      • could add a comment to the pr
    • existing branch might be out of date with head branch
      • could merge from head
      • could delete and recreate
  • allow push to master - so no pr required
  • allow auto merge pr's
  • templates - perform replacement on templated files
  • allow for different dest paths:
    • eg: dependabot.yml=.github/dependabot.yml
  • sync entire dir
    • but what about if dest has extra files in the dir, should they be removed?
  • split into multiple steps in action.yaml

Multiple destinations:

  • action could be setup for each dest
  • or can have one action that supports multiple dest's
    • this would be faster as src would only be checked out once for all dest's

Customize the PR:

  • labels
  • title
  • description
  • reviewers
  • etc
  • provide link to the src repo/change

Alternatives

Benefits over alternatives:

  • Doesn't require the github checkout action so the jobs are simpler and more efficient
  • Doesn't use docker so actions will run in seconds
  • Doesn't use nodeJs
  • Uses original commit author/message in commits to destination repo's
  • Provides link to the original commit
  • Uses hub command line tool rather than direct http requests for creating PR's

Unidirectional Master -> slave 1 -> slave 2 -> slave 3

Bidirectional Slave 1 -> Master Master -> slave 2 -> slave 3

To sync workflow files, token needs workflow permissions

! [remote rejected] testUpdateDir -> testUpdateDir (refusing to allow a Personal Access Token to create or update workflow .github/workflows/ci.yaml without workflow scope)

use post action so that it is always executed for cleanup

paths can be used in the job definition:

on:
  push:
    paths:
      - '**.js'