Skip to content

Commit 2cacdd2

Browse files
committed
create github mirror workflow
1 parent 3566bab commit 2cacdd2

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/mirror.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Mirror to GitLab and Codeberg
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags:
8+
- "*"
9+
workflow_dispatch:
10+
schedule:
11+
- cron: "17 3 * * *" # daily at 03:17 UTC
12+
13+
jobs:
14+
mirror:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Mirror to GitLab and Codeberg (bare mirror clone)
18+
env:
19+
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
20+
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
21+
CODEBERG_USERNAME: ${{ secrets.CODEBERG_USERNAME }}
22+
CODEBERG_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
23+
24+
GITLAB_REPO: "sofos-code"
25+
CODEBERG_REPO: "sofos-code"
26+
run: |
27+
set -euo pipefail
28+
export GIT_TERMINAL_PROMPT=0
29+
30+
GITLAB_REPO_URL="https://oauth2:${GITLAB_TOKEN}@gitlab.com/${GITLAB_USERNAME}/${GITLAB_REPO}.git"
31+
CODEBERG_REPO_URL="https://${CODEBERG_USERNAME}:${CODEBERG_TOKEN}@codeberg.org/${CODEBERG_USERNAME}/${CODEBERG_REPO}.git"
32+
33+
# Create a bare mirror clone of the *current* GitHub repo
34+
git clone --mirror "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" repo.git
35+
cd repo.git
36+
37+
# Push everything (all refs + deletions)
38+
git push --mirror "${GITLAB_REPO_URL}"
39+
git push --mirror "${CODEBERG_REPO_URL}"

0 commit comments

Comments
 (0)