You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,16 +10,21 @@ _This Github Action can come in handy when you have lot of projects like i do._
10
10
_where in some case certain projects users action workflow which are common across projects._
11
11
_Example : [Project 1][project1] & [Project 2][project2] it can be pain to keep all the workflow updated with Github Action's Module's version._
12
12
13
+
This also isn't limited to Github Action yaml files - another use case could be keeping the `.editorconfig`, `LICENSE`, `tsconfig.json`, `tslint.json`, `.gitignore`, `azure-pieplines.yml`, etc. in sync across all your repositories.
14
+
13
15
>_Here where this action comes in and reduces your stress 😉 it can update all your repository actions file based on the config provided_
14
16
15
17
## ⚙️ Configuration
16
18
17
-
|**Argument**| Description |
18
-
| --- | :---: |
19
-
|`github_token`|**Required** Token to use to get repos and write secrets. `${{secrets.GITHUB_TOKEN}}` will not work. instead **Personal Access Token Required***|
20
-
|`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. |
21
-
|`workflow_files`|**Required** New line deliminated regex expressions. workflow files to be copied to provided repositores |
22
-
|`dry_run`| Run everything except for nothing will be pushed. |
19
+
|**Argument**| Defaults | Description |
20
+
| --- | :---: | :---: |
21
+
|`GITHUB_TOKEN`| - |**Required** Token to use to get repos and write secrets. `${{secrets.GITHUB_TOKEN}}` will not work. instead **Personal Access Token Required***|
22
+
|`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. |
23
+
|`WORKFLOW_FILES`| - |**Required** New line deliminated regex expressions. workflow files to be copied to provided repositores |
24
+
|`DRY_RUN`|***false***| Run everything except for nothing will be pushed. |
25
+
|`WORKFLOW_FILES_DIR`|***workflows***| Local Path Where Common Workflow Files Are Located ***Eg : `workflows`***|
26
+
|`AUTO_CREATE_NEW_BRANCH`|***false***| Auto create new brach in a repository if the branch dose not exists |
27
+
|`COMMIT_EACH_FILE`|***false***| if you need to keep track of each file's commit history separate then set it to true |
23
28
24
29
### Personal Access Token Scope
25
30
#### [Github Personal Token](https://github.com/settings/tokens/new?description=gh-workflow-sync) <small> Is required with the below scope </small>
@@ -31,30 +36,107 @@ _Example : [Project 1][project1] & [Project 2][project2] it can be pain to keep
31
36
32
37
***[Click Here To Generate A Token](https://github.com/settings/tokens/new?description=gh-workflow-sync)***
33
38
34
-
### `workflow_files`
35
-
**Example**
39
+
---
40
+
41
+
### `REPOSITORIES` Configuration Examples
42
+
<details><summary><strong>Repository With Default Brach</strong></summary>
43
+
44
+
```yaml
45
+
REPOSITORIES: |
46
+
username/repo
47
+
username/repo2
48
+
```
49
+
50
+
</details>
51
+
52
+
<details><summary><strong>Repositry With Custom Branch</strong></summary>
53
+
54
+
```yaml
55
+
REPOSITORIES: |
56
+
username/repo@dev
57
+
username/repo1@dev2
58
+
```
59
+
> You Can also have same repository multiple times if you provide different branch name
60
+
</details>
61
+
62
+
---
63
+
64
+
### `WORKFLOW_FILES` Configuration Examples
65
+
66
+
<details><summary><strong>Files - Source & Destination File Without Custom Name</strong></summary>
67
+
36
68
```yaml
37
69
WORKFLOW_FILES: |
38
-
your-workflow-file1.yml
39
-
your-workflow-file2.yml
70
+
dependabot.yml
71
+
.github/settings.yml
40
72
```
73
+
> **dependabot.yml** will save in root folder in the repository
74
+
>
75
+
> **.github/settings.yml** will save in `.github` in the repository
76
+
77
+
</details>
78
+
79
+
<details><summary><strong>Files - Source File In Root & Destination File In Custom Location</strong></summary>
80
+
81
+
```yaml
82
+
WORKFLOW_FILES: |
83
+
hello-bot.yml=.github/
84
+
pr-bot.yml=.github/pull-request.yml
85
+
```
86
+
> **hello-bot.yml** will save in `.github` in the repository with the same name
87
+
>
88
+
> **pr-bot.yml** will save in `.github` in the repository with the name `pull-request.yml`
89
+
</details>
90
+
91
+
<details><summary><strong>Folders - Source & Destination Folders Without Custom Name</strong></summary>
41
92
42
-
**Example | Custom File Location**
43
93
```yaml
44
94
WORKFLOW_FILES: |
45
-
./your-folder/your-workflow-file1.yml
46
-
./your-folder/your-workflow-file2.yml
95
+
folder1
96
+
.github/folder2
47
97
```
98
+
> **folder1** will save in root folder in the repository
99
+
>
100
+
> **.github/folder2** will save in `.github` in the repository
101
+
102
+
</details>
103
+
104
+
<details><summary><strong>Folders - Source & Destination Folders With Custom Name</strong></summary>
48
105
49
-
**Example | Custom File Name**
50
-
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
> **folder1** will save inside `REPOSITORY ROOT` in the name of `save-to-folder`
112
+
>
113
+
> **.github/folder2** will save inside `custom-folder` in the name of `save-to-folder2`
114
+
115
+
</details>
55
116
56
117
---
57
118
119
+
## How Files Sync Work ?
120
+
Before copying the **WORKFLOW_FILES** from the source to destination. this action will provide some flexibility.
121
+
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
122
+
123
+
#### Below are the locations that this action search for the file/folder
124
+
* `./{OWNER}/{REPO_NAME}/workflows/{filename}`
125
+
* `./{OWNER}/workflows/{filename}`
126
+
* `./{WORKFLOW_FILES_DIR}/{filename}`
127
+
* `./.github/workflows/{filename}`
128
+
* `./{OWNER}/{REPO_NAME}/{filename}`
129
+
* `./{OWNER}/{filename}`
130
+
* `./{filename}`
131
+
132
+
> if the `settings.yml` is found inside `workflows` folder then the destination is automaitcally forced to `.github/workflows` in the destination repo
133
+
>
134
+
> if the `settings.yml` is outside of `workflows` folder then the destination then its copied to the destination
135
+
136
+
### How this can be useful ?
137
+
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
138
+
139
+
58
140
## 🚀 Usage
59
141
60
142
### Step 1
@@ -65,7 +147,7 @@ if you have used our template repository then edit the file inside `.github/work
65
147
66
148
OR
67
149
68
-
Create a new file in `.github/workflows/` named ***workflow-sync.yml** and copy & paste the below file content
150
+
Create a new file in `.github/workflows/` named **workflow-sync.yml** and copy & paste the below file content
0 commit comments