sync #1242
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sync2gitee | |
on: | |
push: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [sync] | |
jobs: | |
run: | |
name: Sync GitHub to Gitee | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Clone GitHub repository | |
- name: Clone the GitHub repo | |
run: | | |
git clone --depth 1 https://github.com/${{ github.repository }} github-repo | |
# Step 2: Clone Gitee repository | |
- name: Clone the Gitee repo | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.GITEE_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan gitee.com >> ~/.ssh/known_hosts | |
git clone [email protected]:taksssss/tv.git gitee-repo | |
# Step 3: Replace Gitee repo files with GitHub repo files | |
- name: Copy files from GitHub to Gitee | |
run: | | |
rm -rf gitee-repo/* | |
cp -r github-repo/epg gitee-repo/ | |
cp github-repo/README.md gitee-repo/ | |
# Step 4: Commit and push changes to Gitee | |
- name: Commit and push changes to Gitee | |
run: | | |
cd gitee-repo | |
rm -rf .git | |
git init | |
git config --global user.name "${{ secrets.GITEE_USER_NAME }}" | |
git config --global user.email "${{ secrets.GITEE_USER_EMAIL }}" | |
git remote add origin [email protected]:taksssss/tv.git | |
git add . | |
if ! git diff --cached --quiet; then | |
now_time=$(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S') | |
git commit -m "同步 GitHub 更新:$now_time" | |
git checkout -b main || echo "main 分支已存在" | |
git push --force origin main || echo "推送到 Gitee 失败" | |
else | |
echo "没有文件可提交" | |
fi | |
# name: sync2gitee | |
# on: | |
# push: | |
# workflow_dispatch: | |
# repository_dispatch: | |
# types: [sync] | |
# jobs: | |
# run: | |
# name: Sync GitHub to Gitee | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Get current repository name | |
# id: info | |
# uses: actions/[email protected] | |
# with: | |
# github-token: ${{secrets.GH_TOKEN}} | |
# result-encoding: string | |
# script: | | |
# return context.repo.repo; | |
# - name: Mirror the GitHub repos to Gitee | |
# uses: Yikun/hub-mirror-action@master | |
# with: | |
# src: github/taksssss | |
# dst: gitee/taksssss | |
# dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} | |
# dst_token: ${{ secrets.GITEE_TOKEN }} | |
# static_list: '${{ steps.info.outputs.result }}' | |
# account_type: user | |
# force_update: true |