Skip to content

Commit 2e418f8

Browse files
committed
feat: skip sync files when target sync.yaml don't exist
1 parent d3765d4 commit 2e418f8

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.github/workflows/sync-files.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ jobs:
1212
repository:
1313
- .github
1414
steps:
15-
- name: Checkout source repository
16-
uses: actions/checkout@v5
17-
with:
18-
path: source
19-
2015
- name: Create GitHub App token
2116
uses: actions/create-github-app-token@v2
2217
id: gh-app-token
@@ -33,7 +28,23 @@ jobs:
3328
path: target
3429
token: ${{ steps.gh-app-token.outputs.token }}
3530

31+
- name: Decide whether to sync files
32+
id: decide
33+
run: |
34+
if [ -f target/.github/sync.yaml ]; then
35+
echo "sync=true" >> $GITHUB_OUTPUT
36+
else
37+
echo "sync=false" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Checkout source repository
41+
if: steps.decide.outputs.sync == 'true'
42+
uses: actions/checkout@v5
43+
with:
44+
path: source
45+
3646
- name: Copy files
47+
if: steps.decide.outputs.sync == 'true'
3748
run: |
3849
yq -r '.copy[]' target/.github/sync.yaml | while IFS= read -r file; do
3950
source_file="source/$file"
@@ -43,6 +54,7 @@ jobs:
4354
done
4455
4556
- name: Detect sync updates
57+
if: steps.decide.outputs.sync == 'true'
4658
id: updates
4759
working-directory: target
4860
run: |
@@ -53,14 +65,14 @@ jobs:
5365
fi
5466
5567
- name: Output short commit SHA
56-
if: steps.updates.outputs.updated == 'true'
68+
if: steps.decide.outputs.sync == 'true' && steps.updates.outputs.updated == 'true'
5769
id: sha
5870
working-directory: target
5971
run: |
6072
echo "short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
6173
6274
- name: Create Pull Request with applied automatic fixes
63-
if: steps.updates.outputs.updated == 'true'
75+
if: steps.decide.outputs.sync == 'true' && steps.updates.outputs.updated == 'true'
6476
uses: peter-evans/create-pull-request@v7
6577
with:
6678
path: target

0 commit comments

Comments
 (0)