All Projects → varunsridharan → action-github-workflow-sync

varunsridharan / action-github-workflow-sync

Licence: MIT license
Github Action To Sync Github Action's Workflow Files Across Repositories

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to action-github-workflow-sync

changed-files
Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
Stars: ✭ 733 (+1337.25%)
Mutual labels:  workflows, github-actions, github-action
recent-activity
Add your recent activity to your profile readme!
Stars: ✭ 87 (+70.59%)
Mutual labels:  workflows, github-actions, github-action
Github-Android-Action
Android Github Action that builds Android project, runs unit tests and generates debug APK, builds for Github Actions hackathon
Stars: ✭ 29 (-43.14%)
Mutual labels:  github-actions, github-action, github-action-docker
ssh2actions
Connect to GitHub Actions VM via SSH for interactive debugging
Stars: ✭ 62 (+21.57%)
Mutual labels:  workflows, github-actions, github-action
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (+219.61%)
Mutual labels:  workflows, github-actions, github-action
update-container-description-action
github action to update a Docker Hub, Quay or Harbor repository description from a README file
Stars: ✭ 20 (-60.78%)
Mutual labels:  github-workflow, github-actions
delete-run-artifacts-action
github action to delete artifacts at the end of a workflow run
Stars: ✭ 21 (-58.82%)
Mutual labels:  github-workflow, github-actions
jcefbuild
Binary builds of java-cef
Stars: ✭ 160 (+213.73%)
Mutual labels:  github-workflow, github-actions
branch-names
Github action to retrieve branch or tag names with support for all events.
Stars: ✭ 99 (+94.12%)
Mutual labels:  workflows, github-actions
verify-changed-files
Github action to verify file changes that occur during the workflow execution.
Stars: ✭ 62 (+21.57%)
Mutual labels:  workflows, github-actions
restrict-cursing-action
Github Action to prevent cursing and bad language in issues and pull requests
Stars: ✭ 20 (-60.78%)
Mutual labels:  github-actions, github-action
prettier
🔨 Native, blazingly-fast Prettier CLI on Github Actions
Stars: ✭ 19 (-62.75%)
Mutual labels:  github-workflow, github-actions
python-actions-alpha-archived
Please note that this was for the *alpha* version of GitHub Actions for Python.
Stars: ✭ 15 (-70.59%)
Mutual labels:  github-workflow, github-actions
Github Pages Deploy Action
Automatically deploy your project to GitHub Pages using GitHub Actions. This action can be configured to push your production-ready code into any branch you'd like.
Stars: ✭ 2,507 (+4815.69%)
Mutual labels:  github-actions, github-action
pull-request-comment-branch
A GitHub Action to get the head ref and sha of a pull request comment
Stars: ✭ 21 (-58.82%)
Mutual labels:  workflows, github-actions
poc-github-actions
Various proofs of concept examples using Github Actions 🤖
Stars: ✭ 103 (+101.96%)
Mutual labels:  workflows, github-actions
github-run-tests-action
mabl Github Actions implementation
Stars: ✭ 39 (-23.53%)
Mutual labels:  github-actions, github-action
intellij-platform-plugin-verifier-action
GitHub Action for executing the intellij-plugin-verifier
Stars: ✭ 20 (-60.78%)
Mutual labels:  github-actions, github-action
build-godot-action
GitHub action that builds a Godot project for multiple platforms
Stars: ✭ 62 (+21.57%)
Mutual labels:  github-actions, github-action
sentry-releases-action
A GitHub action that creates releases for Sentry.io.
Stars: ✭ 38 (-25.49%)
Mutual labels:  github-actions, github-action

Github Workflow Sync - Github Action

Github Action To Sync Github Action's Workflow Files Across Repositories

https://cdn.svarun.dev/gh/varunsridharan/action-github-workflow-sync/action-banner.jpg

Use Case 🤔 ?

This Github Action can come in handy when you have lot of projects like i do. where in some case certain projects users action workflow which are common across projects. Example : Project 1 & Project 2 it can be pain to keep all the workflow updated with Github Action's Module's version.

This also isn't limited to Github Action yaml files - another use case could be keeping the .editorconfig, LICENSE, tsconfig.json, tslint.json, .gitignore, etc. in sync across all your repositories.

Here where this action comes in and reduces your stress 😉 it can update all your repository actions file based on the config provided

⚙️ Configuration

Argument Defaults Description
GITHUB_TOKEN - Required Token to use to get repos and write secrets. ${{secrets.GITHUB_TOKEN}} will not work. instead Personal Access Token Required*
GIT_URL github.com URL for the instance of github, where repositories should be searched for. Change if using a GHES instance.
REPOSITORIES - Required New line deliminated regex expressions to select repositories. Repositires are limited to those in whcich the token user is an owner or collaborator.
WORKFLOW_FILES - Required New line deliminated regex expressions. workflow files to be copied to provided repositores
DRY_RUN false Run everything except for nothing will be pushed.
WORKFLOW_FILES_DIR workflows Local Path Where Common Workflow Files Are Located Eg : workflows
AUTO_CREATE_NEW_BRANCH false Auto create new brach in a repository if the branch dose not exists
COMMIT_EACH_FILE false if you need to keep track of each file's commit history separate then set it to true
PULL_REQUEST false Set to true if you want the changes to be pushed via pull request.
SKIP_CI false Set to true if you want skip all automations inside target repository.
COMMIT_MESSAGE false You can provide your custom commit message.
RETRY_MODE true Enable retry and throttling octokit plugins to avoid secondary rate limits on github content creation.

Personal Access Token Scope

Github Personal Token Is required with the below scope

https://cdn.svarun.dev/gh/varunsridharan/action-github-workflow-sync/scope.jpg

ℹ️ Full Repo is only required when you need to update private repository if your are updating only public repository then just select public_repo inside repo scope

Click Here To Generate A Token


REPOSITORIES Configuration Examples

Repository With Default Brach
REPOSITORIES: |
    username/repo
    username/repo2
Repositry With Custom Branch
REPOSITORIES: |
    username/repo@dev
    username/repo1@dev2

You Can also have same repository multiple times if you provide different branch name


WORKFLOW_FILES Configuration Examples

  1. If you use = as a file seperator file1.md=myfile.md then file1 from the current repository will be copied to remote repository with the name of myfile.md
  2. If you use != as a file seperator file1.md!=myfile.md then file1 from the current repository will be copied to remote repository with the name of myfile.md only if myfile.md already not exists in the remote repository
Files - Source & Destination File Without Custom Name
WORKFLOW_FILES: |
    dependabot.yml
    .github/settings.yml

dependabot.yml will save in root folder in the repository

.github/settings.yml will save in .github in the repository

Files - Source File In Root & Destination File In Custom Location
WORKFLOW_FILES: |
    hello-bot.yml=.github/
    pr-bot.yml=.github/pull-request.yml

hello-bot.yml will save in .github in the repository with the same name

pr-bot.yml will save in .github in the repository with the name pull-request.yml

Folders - Source & Destination Folders Without Custom Name
WORKFLOW_FILES: |
    folder1
    .github/folder2

folder1 will save in root folder in the repository

.github/folder2 will save in .github in the repository

Folders - Source & Destination Folders With Custom Name
WORKFLOW_FILES: |
    folder1=./save-to-folder
    .github/folder2=custom-folder/save-to-folder2

folder1 will save inside REPOSITORY ROOT in the name of save-to-folder

.github/folder2 will save inside custom-folder in the name of save-to-folder2


How Files Sync Work ?

Before copying the WORKFLOW_FILES from the source to destination. this action will provide some flexibility. this searchs for a file in various locations for example lets take settings.yml as the file that you want to sync for multiple repository

Below are the locations that this action search for the file/folder

  • ./{OWNER}/{REPO_NAME}/workflows/{filename}
  • ./{OWNER}/workflows/{filename}
  • ./{WORKFLOW_FILES_DIR}/{filename}
  • ./.github/workflows/{filename}
  • ./{OWNER}/{REPO_NAME}/{filename}
  • ./{OWNER}/{filename}
  • ./{filename}

if the settings.yml is found inside workflows folder then the destination is automaitcally forced to .github/workflows in the destination repo

if the settings.yml is outside of workflows folder then the destination then its copied to the destination

How this can be useful ?

Lets assume that you want to maintain all the common github files in a single repository and suddenly a repository needs a single file to be changed in that case instead of editing the action yml file. you can just create a folder like {REPO_OWNER}/{REPO_NAME}/{FILE} to copy the overriden file to the destination

🚀 Usage

Step 1

Create a New Repository or use our Repository Template

Step 2

if you have used our template repository then edit the file inside .github/workflows/workflow-sync.yml

OR

Create a new file in .github/workflows/ named workflow-sync.yml and copy & paste the below file content

workflow-sync.yml content

name: Workflow Sync

on:
  push:
    branches:
      - master
env:
  DRY_RUN: false
  REPOSITORIES: |
  
  WORKFLOW_FILES: |

jobs:
  Github_Workflow_Sync:
    runs-on: ubuntu-latest
    steps:
      - name: Fetching Local Repository
        uses: actions/checkout@master
      - name: Running Workflow Sync
        uses: varunsridharan/action-github-workflow-sync@main
        with:
          DRY_RUN: ${{ env.DRY_RUN }}
          REPOSITORIES: ${{ env.REPOSITORIES }}
          WORKFLOW_FILES: ${{ env.WORKFLOW_FILES }}
          GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Troubleshooting

Spacing

Spacing around the equal sign is important. For example, this will not work:

WORKFLOW_FILES: |
  folder/file-sync.yml = folder/test.txt

It passes to the shell file 3 distinct objects

  • folder/file-sync.ymll
  • =
  • folder/test.txt

instead of 1 object

  • folder/file-sync.yml = folder/test.txt

and there is nothing I can do in code to make up for that

Slashes

You do not need (nor want) leading / for the file path on either side of the equal sign

The only time you need / trailing is for folder copies. While a file copy will technically still work with a leading /, a folder copy will not


📝 Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Checkout CHANGELOG.md

🤝 Contributing

If you would like to help, please take a look at the list of issues.

💰 Sponsor

I fell in love with open-source in 2013 and there has been no looking back since! You can read more about me here. If you, or your company, use any of my projects or like what I’m doing, kindly consider backing me. I'm in this for the long run.

  • How about we get to know each other over coffee? Buy me a cup for just $9.99
  • ☕️☕️ How about buying me just 2 cups of coffee each month? You can do that for as little as $9.99
  • 🔰 We love bettering open-source projects. Support 1-hour of open-source maintenance for $24.99 one-time?
  • 🚀 Love open-source tools? Me too! How about supporting one hour of open-source development for just $49.99 one-time ?

📝 License & Conduct

📣 Feedback

  • This repository if this project helped you! 😉
  • Create An 🔧 Issue if you need help / found a bug

Connect & Say 👋


Built With By Varun Sridharan 🇮🇳


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].