Skip to content

Commit 0fa9817

Browse files
committed
.github/workflows/keepalive.yml: update
1 parent 1f54c22 commit 0fa9817

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/keepalive.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ jobs:
2929

3030
- name: Update keepalive timestamp
3131
run: |
32+
# Check if there are any commits in the last 30 days
33+
last_commit_date=$(git log -1 --format=%ct)
34+
current_date=$(date +%s)
35+
days_since_commit=$(( (current_date - last_commit_date) / 86400 ))
36+
37+
if [ $days_since_commit -lt 30 ]; then
38+
echo "Repository has commits within the last 30 days (${days_since_commit} days ago). Skipping keepalive update."
39+
exit 0
40+
fi
41+
42+
echo "No commits in the last ${days_since_commit} days. Updating keepalive timestamp."
3243
echo "Last keepalive: $(date -u)" > .github/keepalive
3344
git config --local user.email "[email protected]"
3445
git config --local user.name "GitHub Action"
@@ -37,5 +48,20 @@ jobs:
3748
echo "No changes to commit"
3849
else
3950
git commit -m "chore: update keepalive timestamp [skip ci]"
51+
52+
# Push to the default branch (xpack)
4053
git push
41-
fi
54+
55+
# Merge into xpack-development branch if it exists
56+
if git ls-remote --heads origin xpack-development | grep -q xpack-development; then
57+
echo "Merging keepalive update into xpack-development branch"
58+
current_branch=$(git rev-parse --abbrev-ref HEAD)
59+
git fetch origin xpack-development
60+
git checkout xpack-development
61+
git merge --no-edit ${current_branch}
62+
git push origin xpack-development
63+
git checkout ${current_branch}
64+
else
65+
echo "xpack-development branch does not exist, skipping merge"
66+
fi
67+
fi

0 commit comments

Comments
 (0)