Skip to content

Works in conjunction with the BetaHuhn/repo-file-sync-action to update the sync.yaml file based on configured templates. Each time it's triggered it will query github for new repositories created from the configured templates and update the sync configuration so that the new repositories are automatically synced from that point forward.

License

Notifications You must be signed in to change notification settings

benjivesterby/update-sync-for-templates

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

Repository files navigation

Update Sync Configuration for BetaHuhn/repo-file-sync-action

Build & Test GitHub tag (latest SemVer)

This action is used to update the sync configuration for the repo-file-sync-action action. Configuring this will allow for repositories created from a configured template to be auto-added to the sync.yaml file.

Configuring the Action

Create your sync file using the group format as described in the repo-file-sync-action

Add the new templates entry to the sync file

group:
  - files:
      - source: file1.txt
        dest: file1.txt
      - source: file2.txt
        dest: file2.txt
    templates: |
      devnw/oss-template
      devnw/template
    repos: |
      devnw/plex

Create your workflow (I used .github/workflows/sync.yml)

name: Sync Files
on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@main
      - name: Sync Template Generated Repositories
        uses: benjivesterby/update-sync-for-templates@main
        with: 
          token: "${{ secrets.GH_PAT }}"
      - name: Run Repo File Sync Action
        uses: BetaHuhn/repo-file-sync-action@latest
        with:
          GH_PAT: ${{ secrets.GH_PAT }}
          CONFIG_PATH: sync.yml
          COMMIT_EACH_FILE: false
  1. Setup the BetaHuhn/repo-file-sync-action action in your GitHub organization.
    1. Example here: https://github.com/devnw/shared
  2. Create a template repository and add your workflow file
    1. Here's a functional example: Template Sync Action
    2. I recommend .github/workflows/sync.yml
  3. Configure your Action
    1. Using the Configuration Options below configure your action.

Example Configuration

name: Template Sync

on: [push, pull_request]

jobs:
  update-sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/[email protected]
      - name: Sync Template Generated Repositories
        uses: benjivesterby/update-sync-for-templates@latest # <-- This is the action
        with: 
          token: "${{ secrets.GH_PAT }}"
      - name: Run Repo File Sync Action
        uses: BetaHuhn/repo-file-sync-action@latest
        with:
          GH_PAT: ${{ secrets.GH_PAT }}
          CONFIG_PATH: sync.yml
          COMMIT_EACH_FILE: false

Personal Access Token

In order for the Action to access your repositories you have to specify a Personal Access Token as the value for GH_PAT (GITHUB_TOKEN will not work). The PAT needs the full repo scope.

Options

Option Required Description
token Personal access token which has permissions the configured templates in the sync file, see here for more.
sync_file The sync yaml file (default: sync.yml)
org Org override for template search (default: template organization)
author_name The name of the user that will be displayed as the author of the commit. (default: Github Action Bot)
author_email The email of the user that will be displayed as the author of the commit. (default: Github Action Bot)

This action is a heavily modified hard fork of original work done by Matthew Elphick [email protected]

About

Works in conjunction with the BetaHuhn/repo-file-sync-action to update the sync.yaml file based on configured templates. Each time it's triggered it will query github for new repositories created from the configured templates and update the sync configuration so that the new repositories are automatically synced from that point forward.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published