Skip to content

Commit 415b2f1

Browse files
committed
fix: handle empty target repository in sync-demo-template workflow
1 parent 87fe124 commit 415b2f1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/workflows/sync-demo-template.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,31 @@ jobs:
148148
149149
- name: Checkout target repository
150150
if: env.secret_configured == 'true'
151+
id: checkout-target
152+
continue-on-error: true
151153
uses: actions/checkout@v4
152154
with:
153155
repository: ${{ env.TARGET_REPO }}
154156
token: ${{ secrets.DEMO_REPO_PAT }}
155157
path: target
156158
fetch-depth: 0
157159

160+
- name: Initialize empty target repository
161+
if: env.secret_configured == 'true' && steps.checkout-target.outcome == 'failure'
162+
env:
163+
DEMO_REPO_PAT: ${{ secrets.DEMO_REPO_PAT }}
164+
run: |
165+
echo "Target repository appears to be empty. Initializing..."
166+
mkdir -p target
167+
cd target
168+
git init
169+
git remote add origin "https://x-access-token:${DEMO_REPO_PAT}@github.com/${{ env.TARGET_REPO }}.git"
170+
git config user.name "github-actions[bot]"
171+
git config user.email "github-actions[bot]@users.noreply.github.com"
172+
# Create an initial empty commit so we have a branch to work with
173+
git commit --allow-empty -m "chore: initialize repository"
174+
echo "✓ Initialized empty repository"
175+
158176
- name: Sync demo files to target
159177
if: env.secret_configured == 'true'
160178
run: |

0 commit comments

Comments
 (0)