-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (46 loc) · 1.51 KB
/
sync.yml
File metadata and controls
53 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Sync GStack to CodeBuddy
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
push:
branches:
- master
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "GStack Bot"
git config --global user.email "bot@github.com"
- name: Check for GStack updates
id: check
run: |
git remote add gstack https://github.com/garrytan/gstack.git 2>/dev/null || true
git fetch gstack main --depth 1 2>/dev/null || git fetch gstack master --depth 1 2>/dev/null || true
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse gstack/main 2>/dev/null || git rev-parse gstack/master 2>/dev/null || echo "$LOCAL")
if [ "$LOCAL" != "$REMOTE" ]; then
echo "updates=true" >> $GITHUB_OUTPUT
else
echo "updates=false" >> $GITHUB_OUTPUT
fi
- name: Commit and tag
if: steps.check.outputs.updates == 'true'
run: |
DATE=$(date +%Y%m%d)
git add -A
git commit -m "Sync with GStack $(date '+%Y-%m-%d')" || true
git tag "v$DATE" -f || true
- name: Push changes
if: steps.check.outputs.updates == 'true'
run: |
git push origin master --force || true
git push origin "v$(date +%Y%m%d)" -f --tags || true