Skip to content

Commit fa5457b

Browse files
committed
ci: add job to mirror repo to Codeberg
- [ci] Add new job `mirror_to_codeberg` (.github/workflows/repo-mirror.yml:52) - [ci] Set `runs-on` to `ubuntu-latest` (repo-mirror.yml:53) - [ci] Add step using `actions/checkout@v3` with `fetch-depth: 0` (repo-mirror.yml:55-57) - [ci] Add `Configure Git` step with user name and email (repo-mirror.yml:58-61) - [ci] Add `Mirror to Codeberg` step using `SSH_PRIVATE_KEY` and `TARGET_URL` secrets (repo-mirror.yml:62-65) - [ci] Create `~/.ssh` directory and write `SSH_PRIVATE_KEY` (repo-mirror.yml:66-67) - [ci] Set 600 permissions for `~/.ssh/id_rsa` (repo-mirror.yml:68) - [ci] Add `codeberg.org` host key to `known_hosts` (repo-mirror.yml:69) - [ci] Execute `git push --force` command (repo-mirror.yml:71) - [style] Add newline at end of file (repo-mirror.yml:50,71)
1 parent 836b04f commit fa5457b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

.github/workflows/repo-mirror.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,26 @@ jobs:
5050
chmod 600 ~/.ssh/id_rsa
5151
ssh-keyscan -t rsa $(echo ${TARGET_URL} | cut -d '@' -f 2 | cut -d ':' -f 1) >> ~/.ssh/known_hosts
5252
# Push local branches and tags, excluding remote refs
53-
git push --force ${TARGET_URL} 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
53+
git push --force ${TARGET_URL} 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
54+
55+
mirror_to_codeberg:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
with:
60+
fetch-depth: 0
61+
- name: Configure Git
62+
run: |
63+
git config --global user.name "GitHub Actions"
64+
git config --global user.email "[email protected]"
65+
- name: Mirror to Codeberg
66+
env:
67+
SSH_PRIVATE_KEY: ${{ secrets.CODEBERG_SSH_PRIVATE_KEY }}
68+
TARGET_URL: ${{ secrets.CODEBERG_REPO_URL }}
69+
run: |
70+
mkdir -p ~/.ssh
71+
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
72+
chmod 600 ~/.ssh/id_rsa
73+
ssh-keyscan -t rsa codeberg.org >> ~/.ssh/known_hosts
74+
# Push local branches and tags, excluding remote refs
75+
git push --force ${TARGET_URL} 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'

0 commit comments

Comments
 (0)