-
Notifications
You must be signed in to change notification settings - Fork 1
39 lines (33 loc) · 1.23 KB
/
mirror.yml
File metadata and controls
39 lines (33 loc) · 1.23 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
name: Mirror to GitLab and Codeberg
on:
push:
branches:
- "**"
tags:
- "*"
workflow_dispatch:
schedule:
- cron: "17 3 * * *" # daily at 03:17 UTC
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Mirror to GitLab and Codeberg (bare mirror clone)
env:
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
CODEBERG_USERNAME: ${{ secrets.CODEBERG_USERNAME }}
CODEBERG_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
GITLAB_REPO: "sofos-web"
CODEBERG_REPO: "sofos-web"
run: |
set -euo pipefail
export GIT_TERMINAL_PROMPT=0
GITLAB_REPO_URL="https://oauth2:${GITLAB_TOKEN}@gitlab.com/${GITLAB_USERNAME}/${GITLAB_REPO}.git"
CODEBERG_REPO_URL="https://${CODEBERG_USERNAME}:${CODEBERG_TOKEN}@codeberg.org/${CODEBERG_USERNAME}/${CODEBERG_REPO}.git"
# Create a bare mirror clone of the *current* GitHub repo
git clone --mirror "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" repo.git
cd repo.git
# Push everything (all refs + deletions)
git push --mirror "${GITLAB_REPO_URL}"
git push --mirror "${CODEBERG_REPO_URL}"