@@ -108,102 +108,3 @@ jobs:
108108 fi
109109 env :
110110 GH_TOKEN : ${{ steps.app-token.outputs.token }}
111-
112- sync-preview :
113- runs-on : ubuntu-latest
114- steps :
115- - name : Generate GitHub App Token
116- id : app-token
117- uses : actions/create-github-app-token@v1
118- with :
119- app-id : ${{ vars.APP_ID }}
120- private-key : ${{ secrets.APP_PRIVATE_KEY }}
121-
122- - uses : actions/checkout@v4
123- with :
124- fetch-depth : 0
125- token : ${{ steps.app-token.outputs.token }}
126-
127- - name : Configure Git
128- run : |
129- git config user.name "github-actions[bot]"
130- git config user.email "github-actions[bot]@users.noreply.github.com"
131-
132- - name : Fetch public preview
133- run : |
134- git remote add public https://github.com/aws/agentcore-cli.git
135- git fetch public preview
136-
137- - name : Sync preview with public/preview
138- run : |
139- git checkout -B preview origin/preview
140-
141- # Check if public/preview is already merged
142- if git merge-base --is-ancestor public/preview HEAD; then
143- echo "✅ preview is already up to date with public/preview"
144- exit 0
145- fi
146-
147- # Merge but exclude .github/workflows/ (GITHUB_TOKEN lacks workflow permission)
148- if git merge public/preview --no-commit --no-ff; then
149- git checkout HEAD -- .github/workflows/ 2>/dev/null || true
150- git commit -m "chore: sync preview with public/preview"
151- git push origin preview
152- echo "✅ preview synced successfully"
153- else
154- echo "⚠️ Conflict detected in preview"
155-
156- # Capture conflicted files before aborting
157- conflicted_files=$(git diff --name-only --diff-filter=U 2>/dev/null || echo "Unable to determine conflicted files")
158- git merge --abort
159-
160- # Check if a sync PR already exists
161- existing_pr=$(gh pr list --base "preview" --search "Merge public/preview" --state open --json number --jq '.[0].number' 2>/dev/null || echo "")
162-
163- if [ -n "$existing_pr" ]; then
164- echo "ℹ️ PR #$existing_pr already exists, skipping"
165- exit 0
166- fi
167-
168- conflict_branch="sync-conflict-preview-$(date +%Y%m%d-%H%M%S)"
169- git checkout -b "$conflict_branch"
170-
171- git merge public/preview --no-commit --no-ff || true
172- git checkout HEAD -- .github/workflows/ 2>/dev/null || true
173- git add -A
174- git commit -m "chore: sync preview with public/preview (conflicts present)
175-
176- This automated sync detected merge conflicts that require manual resolution.
177-
178- Source: public/preview (https://github.com/aws/agentcore-cli)
179- Target: preview
180-
181- Please resolve conflicts and merge this PR." || true
182-
183- git push origin "$conflict_branch"
184-
185- gh pr create \
186- --title "🔀 [Sync Conflict] Merge public/preview → preview" \
187- --body "## Automated Sync Conflict
188-
189- This PR was automatically created because merging \`public/preview\` into \`preview\` encountered conflicts.
190-
191- **Source:** \`preview\` from [aws/agentcore-cli](https://github.com/aws/agentcore-cli)
192- **Target:** \`preview\`
193-
194- ### Action Required
195- 1. \`git fetch origin && git checkout $conflict_branch\`
196- 2. Resolve merge conflicts
197- 3. \`git add . && git commit\`
198- 4. \`git push origin $conflict_branch\`
199- 5. Merge this PR
200-
201- ### Files with Conflicts
202- \`\`\`
203- $conflicted_files
204- \`\`\`" \
205- --base "preview" \
206- --head "$conflict_branch" || echo "⚠️ Failed to create PR"
207- fi
208- env :
209- GH_TOKEN : ${{ steps.app-token.outputs.token }}
0 commit comments