Compare commits
2 commits
bfded86513
...
a7051622b5
Author | SHA1 | Date | |
---|---|---|---|
a7051622b5 | |||
710fb701c7 |
1 changed files with 47 additions and 0 deletions
47
.github/workflows/forgejo-mirror.yml
vendored
Normal file
47
.github/workflows/forgejo-mirror.yml
vendored
Normal 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/*
|
Loading…
Add table
Add a link
Reference in a new issue