Skip to content

Commit 630b1f0

Browse files
authored
Allow setting inline config (#7)
1 parent 885895a commit 630b1f0

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ user/repo2@develop:
145145
- path/to/file2.txt
146146
```
147147

148+
Alternatively for simple, or dynamic configurations you can use the `INLINE_CONFIG` to define the configuration inline in the workflow file:
149+
150+
```yml
151+
- name: Run GitHub File Sync
152+
uses: BetaHuhn/repo-file-sync-action@v1
153+
with:
154+
GH_PAT: ${{ secrets.GH_PAT }}
155+
INLINE_CONFIG: |
156+
user/repo:
157+
- path/to/file.txt
158+
user/repo2@develop:
159+
- path/to/file2.txt
160+
```
161+
148162
There are multiple ways to specify which files to sync to each individual repository.
149163

150164
### List individual file(s)

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: |
1616
The path for the sync configuration file
1717
required: false
18+
INLINE_CONFIG:
19+
description: |
20+
The config provided inline as a YAML object. This will override the CONFIG_PATH if both are provided.
21+
required: false
1822
IS_FINE_GRAINED:
1923
description: |
2024
Label GH_PAT as a fine grained token

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ try {
4242
key: 'CONFIG_PATH',
4343
default: '.github/sync.yml'
4444
}),
45+
INLINE_CONFIG: getInput({
46+
key: 'INLINE_CONFIG',
47+
default: ''
48+
}),
4549
IS_FINE_GRAINED: getInput({
4650
key: 'IS_FINE_GRAINED',
4751
default: false
@@ -207,9 +211,15 @@ const parseFiles = (files) => {
207211
}
208212

209213
export async function parseConfig() {
210-
const fileContent = await fs.promises.readFile(context.CONFIG_PATH)
214+
let configObject
211215

212-
const configObject = yaml.load(fileContent.toString())
216+
if (context.INLINE_CONFIG) {
217+
configObject = yaml.load(context.INLINE_CONFIG)
218+
} else {
219+
const fileContent = await fs.promises.readFile(context.CONFIG_PATH)
220+
221+
configObject = yaml.load(fileContent.toString())
222+
}
213223

214224
const result = {}
215225

0 commit comments

Comments
 (0)