Files
gentoo-zh/.github/workflows/mirror-to-codeberg.yml
T
Zakk f977f4fc01 mirror-to-codeberg.yml: restrict when the mirror runs
因为 GitHub 不向 Dependabot 触发的运行提供仓库 secrets,`CODEBERG_SSH_KEY` 取到空值、推送必定失败,所以跳过
Dependabot 的运行。

因为这个 workflow 每次都 `git clone --mirror` 整个仓库并推送全部 ref,一次运行就已同步所有分支,所以 push 只在 master 和
tag 上触发。

Signed-off-by: Zakk <zakk@gentoozh.org>
2026-08-01 21:40:20 +10:00

34 lines
1003 B
YAML

name: mirror to codeberg
on:
workflow_dispatch:
push:
branches: [master]
tags: ['**']
delete:
schedule:
- cron: '40 4 * * *'
concurrency:
group: mirror-to-codeberg
jobs:
mirror:
runs-on: ubuntu-latest
if: github.repository == 'gentoo-zh/overlay' && github.actor != 'dependabot[bot]'
steps:
- name: Clone GitHub repository (bare mirror)
run: git clone --mirror "https://github.com/${GITHUB_REPOSITORY}.git" repo.git
- name: Push branches and tags to Codeberg
working-directory: repo.git
env:
SSH_KEY: ${{ secrets.CODEBERG_SSH_KEY }}
run: |
mkdir -p ~/.ssh
printf '%s\n' "$SSH_KEY" > ~/.ssh/codeberg_mirror
chmod 600 ~/.ssh/codeberg_mirror
ssh-keyscan codeberg.org >> ~/.ssh/known_hosts 2>/dev/null
export GIT_SSH_COMMAND="ssh -i ~/.ssh/codeberg_mirror"
git push --prune git@codeberg.org:gentoo-zh/overlay.git \
'+refs/heads/*:refs/heads/*' '+refs/tags/*:refs/tags/*'