Compare commits

...

2 commits

Author SHA1 Message Date
a7051622b5 fixed git sync
Some checks failed
build-latex / build (push) Has been cancelled
2025-06-20 23:58:06 +02:00
710fb701c7 added github clone workflow 2025-06-20 23:49:42 +02:00

47
.github/workflows/forgejo-mirror.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: Mirror Forgejo to GitHub
on:
schedule:
- cron: '0 * * * *' # every hour
workflow_dispatch:
env:
FORGEJO_OWNER: Jonas_Jones
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Set GitHub owner and repo variables
id: vars
run: |
OWNER=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f1)
REPO=$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f2)
echo "OWNER=$OWNER" >> $GITHUB_OUTPUT
echo "REPO=$REPO" >> $GITHUB_OUTPUT
- name: Clone Forgejo repo and push branches and tags safely
env:
FORGEJO_OWNER: ${{ env.FORGEJO_OWNER }}
OWNER: ${{ steps.vars.outputs.OWNER }}
REPO: ${{ steps.vars.outputs.REPO }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FORGEJO_URL="https://git.jonasjones.dev/${FORGEJO_OWNER}/${REPO}.git"
GITHUB_REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER}/${REPO}.git"
git clone --bare "$FORGEJO_URL" forgejo.git
cd forgejo.git
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git remote add github "$GITHUB_REPO_URL"
git pull
# Push all branches without deleting any remote branch
git push github refs/heads/*:refs/heads/*
# Push all tags
git push github refs/tags/*:refs/tags/*