Skip to content

new picture

new picture #4

Workflow file for this run

name: Sync Changed Files to GitLab
on:
push:
branches: [main]
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