Code Monkey home page Code Monkey logo

actions-template-sync's Introduction

actions-template-sync

All Contributors

Lint

It is possible to create repositories within Github with GitHub templates. This is a nice approach to have some boilerplate within your repository. Over the time the template repository will get some code changes. The problem is that the already created repositories won't know about those changes. This GitHub action will help you to keep track of the template changes.

Features

  • Sync template repository with the current repository
  • Ignore files and folders from syncing using a .templatesyncignore file

Usage

GitHub Actions

Add this configuration to your github action

# File: .github/workflows/template-sync.yml

on:
    # cronjob trigger
  schedule:
  - cron:  "0 0 1 * *"
  # manual trigger
  workflow_dispatch:
jobs:
  repo-sync:
    runs-on: ubuntu-latest

    steps:
      # To use this repository's private action, you must check out the repository
      - name: Checkout
        uses: actions/checkout@v3
      - name: actions-template-sync
        uses: AndreasAugustin/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          source_repo_path: <owner/repo>
          upstream_branch: <target_branch> # defaults to main
          pr_labels: <label1>,<label2>[,...] # defaults to chore,template-sync

You will receive a pull request within your repository if there are some changes available.

Configuration parameters

Variable Description Required [Default]
github_token Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }} true
source_repo_path Repository path of the template true
upstream_branch The target branch true main
source_repo_ssh_private_key [optional] private ssh key for the source repository. E.q. useful if using a private template repository. see false
pr_labels [optional] comma separated list. pull request labels. Must be already created. false chore,template_sync
hostname [optional] the hostname of the repository false github.com

Example

This repo uses this template and this action from the marketplace. See the definition here

Trigger

You can use all triggers which are supported for GitHub actions

Private template repository

If you have a private template repository.

SSH

You have various options to use ssh keys with GitHub. An example are deployment keys. For our use case write permissions are not needed. Within the repository where the GitHub action is enabled add a secret (e.q. SOURCE_REPO_SSH_PRIVATE_KEY) with the content of your private SSH key. Make sure that the read permissions of that secret fulfil your use case. Set the optional source_repo_ssh_private_key input parameter.

jobs:
  repo-sync:
    runs-on: ubuntu-latest

    steps:
      # To use this repository's private action, you must check out the repository
      - name: Checkout
        uses: actions/checkout@v3
      - name: actions-template-sync
        uses: AndreasAugustin/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # <owner/repo>, should be within secrets
          upstream_branch: ${{ secrets.TARGET_BRANCH }} #<target_branch> # defaults to main
          pr_labels: <label1>,<label2>[,...] # defaults to chore,template-sync
          source_repo_ssh_private_key: ${{ secrets.SOURCE_REPO_SSH_PRIVATE_KEY }} # contains the private ssh key of the private repository

Ignore Files

Create a .templatesyncignore file. Just like writing a .gitignore file, follow the glob pattern in defining the files and folders that should be excluded from syncing with the template repository.

Debug

You must create a secret named ACTIONS_STEP_DEBUG with the value true to see the debug messages set by this command in the log. For more information, see "Enabling debug logging."

DEV

The development environment targets are located in the Makefile

make help

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


andy Augustin

๐Ÿ“– ๐Ÿ’ป ๐Ÿ‘€ ๐Ÿ›ก๏ธ

Ugo Pattacini

๐Ÿ“–

Jose Gabrielle Rivera

๐Ÿ’ป

P.D. Rittenhouse

๐Ÿค”

Daniel Boll

๐Ÿ›

albertschwarzkopf

๐Ÿค”

Akul Pillai

๐Ÿ›ก๏ธ

Stefan Riembauer

๐Ÿค”

Fabrizio Cacicia

๐Ÿ›ก๏ธ ๐Ÿ›

This project follows the all-contributors specification. Contributions of any kind welcome!

actions-template-sync's People

Contributors

allcontributors[bot] avatar andreasaugustin avatar dependabot-preview[bot] avatar dependabot[bot] avatar jgarivera avatar pattacini avatar

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.