Skip to content

Commit 2136702

Browse files
committed
feat: sync files with a different source and destination path
1 parent 3f74435 commit 2136702

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

.github/workflows/sync-files.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ jobs:
4747
if: steps.decide.outputs.sync == 'true'
4848
run: |
4949
yq -r '.copy[]' target/.github/sync.yaml | while IFS= read -r file; do
50-
source_file="source/$file"
51-
target_file="target/$file"
52-
mkdir -p "$(dirname "$target_file")"
53-
cp "$source_file" "$target_file"
50+
if [[ "$file" == *:* ]]; then
51+
IFS=':' read -r source_file destination_file <<< "$file"
52+
else
53+
source_file="$file"
54+
destination_file="$file"
55+
fi
56+
source_path="source/$source_file"
57+
destination_path="target/$destination_file"
58+
mkdir -p "$(dirname "$destination_path")"
59+
cp "$source_path" "$destination_path"
5460
done
5561
5662
- name: Detect sync updates

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ plugins:
100100
Configure target repositories:
101101

102102
- Target repositories are specified at the source repository [Sync Files Workflow](.github/workflows/sync-files.yaml) in the matrix.
103-
- Files to sync are specified in the target repository file `.github/sync.yaml`:
103+
- Files to sync are specified in the target repository file `.github/sync.yaml`.
104+
- `copy` section contains an array of files to copy, either in `source/file` or `source/file:destination/file` form. Destination subdirectories are created when necessary.
104105

105106
```yaml
106107
---
107108
copy:
108-
- .github/workflows/semantic-release.yaml
109-
- .releaserc.yaml
109+
- examples/workflows/semantic-release.yaml:.github/workflows/semantic-release.yaml
110+
- .releaserc.yaml
110111
```
111112

112113
## Credits and Acknowledgments

0 commit comments

Comments
 (0)