|
| 1 | +<p align="center"><img src="https://cdn.svarun.dev/gh/actions-small.png" width="150px"/></p> |
| 2 | + |
| 3 | +# Github Workflow Sync - ***Github Action*** |
| 4 | +Github Action To Sync Github Action's Workflow Files Across Repositories |
| 5 | + |
| 6 | +## Use Case 🤔 ? |
| 7 | +_This Github Action can come in handy when you have lot of projects like i do._ |
| 8 | +_where in some case certain projects users action workflow which are common across projects._ |
| 9 | +_Example : [Project 1][project1] & [Project 2][project2] it can be pain to keep all the workflow updated with Github Action's Module's version._ |
| 10 | + |
| 11 | +>_Here where this action comes in and reduces your stress 😉 it can update all your repository actions file based on the config provided_ |
| 12 | +
|
| 13 | +## ⚙️ Configuration |
| 14 | + |
| 15 | +| **Argument** | Description | |
| 16 | +| --- | :---: | |
| 17 | +| `github_token` | **Required** Token to use to get repos and write secrets. `${{secrets.GITHUB_TOKEN}}` will not work. instead **Personal Access Token Required*** | |
| 18 | +| `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. | |
| 19 | +| `workflow_files` | **Required** New line deliminated regex expressions. workflow files to be copied to provided repositores | |
| 20 | +| `dry_run` | Run everything except for nothing will be pushed. | |
| 21 | + |
| 22 | +### Personal Access Token Scope |
| 23 | +#### [Github Personal Token](https://github.com/settings/tokens/new?description=gh-workflow-sync) <small> Is required with the below scope </small> |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +> ℹ️ Full ***Repo*** is only required when you need to update private repository |
| 28 | +> if your are updating only public repository then just select `public_repo` inside ***repo*** scope |
| 29 | +
|
| 30 | +***[Click Here To Generate A Token](https://github.com/settings/tokens/new?description=gh-workflow-sync)*** |
| 31 | + |
| 32 | +### `workflow_files` |
| 33 | +**Example** |
| 34 | +```yaml |
| 35 | +WORKFLOW_FILES: | |
| 36 | + your-workflow-file1.yml |
| 37 | + your-workflow-file2.yml |
| 38 | +``` |
| 39 | +
|
| 40 | +**Example | Custom File Location** |
| 41 | +```yaml |
| 42 | +WORKFLOW_FILES: | |
| 43 | + ./your-folder/your-workflow-file1.yml |
| 44 | + ./your-folder/your-workflow-file2.yml |
| 45 | +``` |
| 46 | +
|
| 47 | +**Example | Custom File Name** |
| 48 | +Action will locate `your-workflow-file1.yml` from in your repository where this action is used & `your-custom-workflow-file.yml` will be the new file name which will be used to store in the repository you provided |
| 49 | +```yaml |
| 50 | +WORKFLOW_FILES: | |
| 51 | + ./your-folder/your-workflow-file1.yml=your-custom-workflow-file.yml |
| 52 | +``` |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## 🚀 Usage |
| 57 | + |
| 58 | +### Step 1 |
| 59 | +Create a [New Repository](https://github.com/new) or use our [Repository Template](https://github.com/varunsridharan/template-github-workflow-sync) |
| 60 | + |
| 61 | +### Step 2 |
| 62 | +if you have used our template repository then edit the file inside `.github/workflows/workflow-sync.yml` |
| 63 | + |
| 64 | +OR |
| 65 | + |
| 66 | +Create a new file in `.github/workflows/` named ***workflow-sync.yml** and copy & paste the below file content |
| 67 | + |
| 68 | +#### `workflow-sync.yml` content |
| 69 | +```yaml |
| 70 | +name: Workflow Sync |
| 71 | +
|
| 72 | +on: |
| 73 | + push: |
| 74 | + branches: |
| 75 | + - master |
| 76 | +env: |
| 77 | + DRY_RUN: false |
| 78 | + REPOSITORIES: | |
| 79 | + |
| 80 | + WORKFLOW_FILES: | |
| 81 | +
|
| 82 | +jobs: |
| 83 | + Github_Workflow_Sync: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Fetching Local Repository |
| 87 | + uses: actions/checkout@master |
| 88 | + - name: Running Workflow Sync |
| 89 | + uses: varunsridharan/action-github-workflow-sync@master |
| 90 | + with: |
| 91 | + DRY_RUN: ${{ env.DRY_RUN }} |
| 92 | + REPOSITORIES: ${{ env.REPOSITORIES }} |
| 93 | + WORKFLOW_FILES: ${{ env.WORKFLOW_FILES }} |
| 94 | + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 95 | +
|
| 96 | +``` |
| 97 | +--- |
| 98 | + |
| 99 | +## 🤝 Contributing |
| 100 | +If you would like to help, please take a look at the list of [issues](issues/). |
| 101 | + |
| 102 | +## 💰 Sponsor |
| 103 | +[I][twitter] fell in love with open-source in 2013 and there has been no looking back since! You can read more about me [here][website]. |
| 104 | +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. |
| 105 | + |
| 106 | +- ☕ How about we get to know each other over coffee? Buy me a cup for just [**$9.99**][buymeacoffee] |
| 107 | +- ☕️☕️ How about buying me just 2 cups of coffee each month? You can do that for as little as [**$9.99**][buymeacoffee] |
| 108 | +- 🔰 We love bettering open-source projects. Support 1-hour of open-source maintenance for [**$24.99 one-time?**][paypal] |
| 109 | +- 🚀 Love open-source tools? Me too! How about supporting one hour of open-source development for just [**$49.99 one-time ?**][paypal] |
| 110 | + |
| 111 | +## 📝 License & Conduct |
| 112 | +- [**General Public License v3.0 license**](LICENSE) © [Varun Sridharan](website) |
| 113 | +- [Code of Conduct](code-of-conduct.md) |
| 114 | + |
| 115 | +## 📣 Feedback |
| 116 | +- ⭐ This repository if this project helped you! :wink: |
| 117 | +- Create An [🔧 Issue](issues/) if you need help / found a bug |
| 118 | + |
| 119 | +## Connect & Say 👋 |
| 120 | +- **Follow** me on [👨💻 Github][github] and stay updated on free and open-source software |
| 121 | +- **Follow** me on [🐦 Twitter][twitter] to get updates on my latest open source projects |
| 122 | +- **Message** me on [📠 Telegram][telegram] |
| 123 | +- **Follow** my pet on [Instagram][sofythelabrador] for some _dog-tastic_ updates! |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +<p align="center"> |
| 128 | +<i>Built With ♥ By <a href="https://go.svarun.dev/twitter" target="_blank" rel="noopener noreferrer">Varun Sridharan</a> 🇮🇳 </i> |
| 129 | +</p> |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +<!-- Personl Links --> |
| 134 | +[project1]: https://github.com/varunsridharan/wc-product-subtitle/blob/master/.github/workflows/push-to-master.yml |
| 135 | +[project2]: https://github.com/varunsridharan/sku-shortlink-for-woocommerce/blob/master/.github/workflows/push-to-master.yml |
| 136 | +[paypal]: https://go.svarun.dev/paypal |
| 137 | +[buymeacoffee]: https://go.svarun.dev/buymeacoffee |
| 138 | +[sofythelabrador]: https://www.instagram.com/sofythelabrador/ |
| 139 | +[github]: https://go.svarun.dev/github/ |
| 140 | +[twitter]: https://go.svarun.dev/twitter/ |
| 141 | +[telegram]: https://go.svarun.dev/telegram/ |
| 142 | +[email]: https://go.svarun.dev/contact/email/ |
| 143 | +[website]: https://go.svarun.dev/website/ |
0 commit comments