-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (37 loc) · 1.33 KB
/
GLsync.yml
File metadata and controls
46 lines (37 loc) · 1.33 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
name: Sync Changed Files to GitLab
on:
workflow_dispatch:
jobs:
sync-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub repo (source)
uses: actions/checkout@v4
- name: Set up GitLab repo (destination)
env:
GITLAB_TOKEN: ${{ secrets.GLPAT }}
run: |
# Clone GitLab repo
git clone https://oauth2:${GITLAB_TOKEN}@gitlab.tudelft.nl/opentextbooks/Demolab.git gitlab-mirror
# Set up Git config
cd gitlab-mirror
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
cd ..
- name: Copy only changed files
run: |
# Compare and copy only changed files from GitHub to GitLab clone
rsync -av --delete --exclude='.git' --exclude='gitlab-mirror/' ./ ./gitlab-mirror/
- name: Commit and push changes
env:
GITLAB_TOKEN: ${{ secrets.GLPAT }}
run: |
cd gitlab-mirror
git add .
# Only commit if there are changes
if ! git diff --cached --quiet; then
git commit -m "Sync changed files from GitHub"
git push https://oauth2:${GITLAB_TOKEN}@gitlab.tudelft.nl/opentextbooks/Demolab.git main
else
echo "No changes to commit"
fi