Giter VIP home page Giter VIP logo

benjivesterby / update-sync-for-templates Goto Github PK

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

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: MIT License

TypeScript 96.41% JavaScript 3.59%
template-sync sync file-sync github-workflow github-actions workflow-sync github-action-workflow-sync sync-action workflow-files

update-sync-for-templates's Introduction

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]

update-sync-for-templates's People

Contributors

benjivesterby avatar dependabot[bot] avatar

Watchers

 avatar  avatar

update-sync-for-templates's Issues

[Bug]: Does not remove deleted repos from the sync file

🐞 Describe the bug

If a repo that is referenced in sync.yml is deleted, this action will not update the file to remove it, so the next run of the BetaHuhn/repo-file-sync-action will fail because it references a deleted repo.

📚 To Reproduce

  1. Configure the action and workflow as per the README
  2. Create new repo from the template
  3. Run the action to update the sync.yml file
  4. Delete the new repo
  5. Run the action again to update the sync.yml

You will find that the sync.yml file has not been updated - it still contains the deleted repo name

💡 Expected behavior

The sync.yml file should no longer include the deleted repo.
In the same scenario, the https://github.com/maael/template-repository-usage-action action you forked will correctly update the README.md file and it no longer contains the deleted repo.
I suspect this is because it is simply replacing the entire section of README.md with whatever if finds where you are simply ensuring that the repos you find exist in the list of repos in the sync.yml file

⚙️ Environment

  • Release Version: benjivesterby/update-sync-for-templates@main
  • OS: ubuntu-latest

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.