Skip to content

Commit 4134a10

Browse files
authored
fix: Reverse sync workflow (#6)
1 parent f9cbc2c commit 4134a10

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

.github/workflows/reverse-sync-push.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ jobs:
8484
run: |
8585
pr_number="${{ steps.check_pr_commit.outputs.pr_number }}"
8686
87+
echo "👀 Looking for PR $pr_number ..."
88+
89+
8790
# Get PR information using GitHub API
8891
pr_info=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
8992
"https://api.github.com/repos/${{ github.repository }}/pulls/$pr_number")
9093
94+
95+
echo "👀 PR data $pr_info ..."
96+
9197
pr_title=$(echo "$pr_info" | jq -r '.title')
9298
pr_author=$(echo "$pr_info" | jq -r '.user.login')
9399
pr_url=$(echo "$pr_info" | jq -r '.html_url')
@@ -169,6 +175,9 @@ jobs:
169175
echo "📑 Will only sync these paths: $SYNCED_PATHS"
170176
git format-patch $parent_commit..$commit_sha --stdout -- $SYNCED_PATHS > changes.patch
171177
178+
echo "📋 Generated Patch: "
179+
cat changes.patch
180+
172181
cd target-docs
173182
174183
# Apply the patch
@@ -205,12 +214,20 @@ jobs:
205214
run: |
206215
cd target-docs
207216
217+
echo "🔍 Checking for changes..."
218+
219+
git status
220+
221+
echo "=> Adding changes..."
222+
208223
git add .
209224
225+
echo "==> Checking if there are staged changes..."
210226
if git diff --staged --quiet; then
211227
echo "has_changes=false" >> $GITHUB_OUTPUT
212228
echo "ℹ️ No changes to commit"
213229
else
230+
echo "=> Changes detected..."
214231
echo "has_changes=true" >> $GITHUB_OUTPUT
215232
216233
pr_number="${{ steps.check_pr_commit.outputs.pr_number }}"
@@ -219,20 +236,26 @@ jobs:
219236
pr_url="${{ steps.get_pr_info.outputs.pr_url }}"
220237
commit_sha="${{ steps.check_pr_commit.outputs.commit_sha }}"
221238
239+
echo "=> Creating commit message..."
240+
echo " - PR Number: $pr_number"
241+
echo " - PR Title: $pr_title"
242+
echo " - PR Author: $pr_author"
243+
echo " - PR URL: $pr_url"
244+
echo " - Commit SHA: $commit_sha"
245+
222246
# Create commit message with reverse sync marker
223-
cat > commit_message.txt << EOF
224-
[reverse-sync] Sync documentation changes from devops-pipelines-docs PR #$pr_number
225247
226-
This commit incorporates changes from external contributors to the devops-pipelines-docs repository.
248+
echo "[reverse-sync] Sync documentation changes from devops-pipelines-docs PR #$pr_number" > commit_message.txt
249+
echo "" >> commit_message.txt
250+
echo "- Title: $pr_title" >> commit_message.txt
251+
echo "- Author: $pr_author" >> commit_message.txt
252+
echo "- URL: $pr_url" >> commit_message.txt
253+
echo "- Commit: $commit_sha" >> commit_message.txt
227254
228-
📋 Original PR Details:
229-
- Title: $pr_title
230-
- Author: $pr_author
231-
- URL: $pr_url
232-
- Commit: $commit_sha
255+
echo "=> Commit message:"
256+
cat commit_message.txt
233257
234-
🔄 This is a reverse sync commit - it should not trigger forward sync.
235-
EOF
258+
echo "=> Committing changes..."
236259
237260
git commit -F commit_message.txt
238261
rm commit_message.txt

0 commit comments

Comments
 (0)