Skip to content

Commit 8cdb8f0

Browse files
committed
Modify github action
1 parent 257b6ea commit 8cdb8f0

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

.github/workflows/sync_s2mpj.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ jobs:
2626
2727
- name: Sync and Filter Files
2828
run: |
29-
# 1. Clone the upstream repository to a temporary directory
30-
# We only need the latest commit (depth 1) to save bandwidth and time
29+
# 1. Attempt to clone the upstream repository
30+
# We check the exit code to ensure the clone was successful before proceeding.
3131
echo "Cloning upstream repository..."
32-
git clone --depth 1 https://github.com/GrattonToint/S2MPJ.git temp_upstream
32+
if ! git clone --depth 1 https://github.com/GrattonToint/S2MPJ.git temp_upstream; then
33+
echo "::error::Failed to fetch upstream repository. Aborting sync to prevent data loss."
34+
exit 1
35+
fi
36+
37+
echo "Upstream cloned successfully. Syncing files..."
3338
3439
# 2. Clean managed files in current workspace for fresh sync
35-
# We purposefully only remove the specific files/folders we are syncing.
36-
# This allows the user to keep other custom files (like README.md) in the root.
37-
echo "Cleaning managed files matching upstream subset..."
40+
# Only remove the specific files/folders we are syncing.
3841
mkdir -p src
3942
rm -rf src/python_problems src/list_of_python_problems src/s2mpjlib.py
4043
@@ -66,13 +69,13 @@ jobs:
6669
rm -rf temp_upstream
6770
6871
# 5. Commit and push the changes
69-
git add .
72+
git add src
7073
7174
# Check if there are any changes staged for commit
72-
# 'git diff --staged --quiet' returns 0 (true) if there are no changes
7375
if git diff --staged --quiet; then
74-
echo "No changes detected. Skipping push."
76+
echo "No changes detected. The 'src' folder is up to date."
7577
else
78+
echo "Updates detected. Committing changes..."
7679
git commit -m "Auto-sync subset files from GrattonToint/S2MPJ"
7780
git push
7881
fi

0 commit comments

Comments
 (0)