Skip to content

简化镜像仓库同步 workflow#5004

Merged
Glavo merged 6 commits intoHMCL-dev:mainfrom
Glavo:cnb
Dec 19, 2025
Merged

简化镜像仓库同步 workflow#5004
Glavo merged 6 commits intoHMCL-dev:mainfrom
Glavo:cnb

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Dec 19, 2025

No description provided.

@Glavo Glavo changed the title 支持手动触发 CNB 同步 简化镜像仓库同步 workflow Dec 19, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates mirror repository synchronization workflows by replacing two separate workflow files (gitee.yml and cnb.yml) with a single unified mirror.yml workflow that uses a matrix strategy to handle multiple mirror targets.

Key Changes:

  • Created a unified mirror.yml workflow using matrix strategy to sync to both Gitee and CNB repositories
  • Integrated mirror workflow call into the release.yml workflow
  • Removed redundant gitee.yml and cnb.yml workflow files

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
.github/workflows/mirror.yml New unified workflow with matrix strategy for syncing to multiple mirror repositories (Gitee and CNB)
.github/workflows/release.yml Added step to invoke the new mirror workflow during release process
.github/workflows/gitee.yml Removed - functionality consolidated into mirror.yml
.github/workflows/cnb.yml Removed - functionality consolidated into mirror.yml

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

on:
workflow_dispatch:
workflow_call:
push:
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on.push trigger should specify branches to avoid running the mirror workflow on every push to any branch. Consider adding a branch filter like branches: [main, master] to avoid unnecessary workflow runs and potential race conditions when multiple branches are pushed simultaneously.

Suggested change
push:
push:
branches:
- main
- master

Copilot uses AI. Check for mistakes.
name: Mirror to ${{ matrix.target.name }}
if: ${{ github.repository == 'HMCL-dev/HMCL' }}
runs-on: ubuntu-latest
steps:
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkout step is missing. The git clone --mirror command needs to clone from GitHub, but there's no checkout of the source repository. While the command uses GITHUB_REPOSITORY environment variable, you should add a checkout step or ensure the GITHUB_REPOSITORY variable is properly set in the environment.

Suggested change
steps:
- name: Mirror GitHub to ${{ matrix.target.name }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +20
user: 'GITEE_SYNC_USERNAME'
token: 'GITEE_SYNC_TOKEN'
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: 'CNB_SYNC_USERNAME'
token: 'CNB_SYNC_TOKEN'
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matrix strategy contains string values for 'user' and 'token' fields, but these should reference the actual secret names without quotes. The current configuration will attempt to access secrets with literal string keys 'GITEE_SYNC_USERNAME' rather than the intended secret names. Change to user: GITEE_SYNC_USERNAME without quotes.

Suggested change
user: 'GITEE_SYNC_USERNAME'
token: 'GITEE_SYNC_TOKEN'
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: 'CNB_SYNC_USERNAME'
token: 'CNB_SYNC_TOKEN'
user: GITEE_SYNC_USERNAME
token: GITEE_SYNC_TOKEN
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: CNB_SYNC_USERNAME
token: CNB_SYNC_TOKEN

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +20
user: 'GITEE_SYNC_USERNAME'
token: 'GITEE_SYNC_TOKEN'
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: 'CNB_SYNC_USERNAME'
token: 'CNB_SYNC_TOKEN'
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matrix strategy contains string values for 'user' and 'token' fields, but these should reference the actual secret names without quotes. The current configuration will attempt to access secrets with literal string keys 'CNB_SYNC_USERNAME' rather than the intended secret names. Change to user: CNB_SYNC_USERNAME without quotes.

Suggested change
user: 'GITEE_SYNC_USERNAME'
token: 'GITEE_SYNC_TOKEN'
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: 'CNB_SYNC_USERNAME'
token: 'CNB_SYNC_TOKEN'
user: GITEE_SYNC_USERNAME
token: GITEE_SYNC_TOKEN
- name: CNB
repo: cnb.cool/HMCL-dev/HMCL
user: CNB_SYNC_USERNAME
token: CNB_SYNC_TOKEN

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +28
- name: Mirror GitHub to ${{ matrix.target.name }}
run: |
git clone --mirror "https://github.com/$GITHUB_REPOSITORY.git" -- repo
cd repo
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential security risk: The mirror workflow exposes credentials in the git push URL. While GitHub masks secrets in logs, consider using git credential helpers or SSH keys for a more secure approach. Additionally, ensure the secrets have minimal required permissions (only repository write access).

Suggested change
- name: Mirror GitHub to ${{ matrix.target.name }}
run: |
git clone --mirror "https://github.com/$GITHUB_REPOSITORY.git" -- repo
cd repo
env:
MIRROR_USER: ${{ secrets[matrix.target.user] }}
MIRROR_TOKEN: ${{ secrets[matrix.target.token] }}
run: |
git clone --mirror "https://github.com/$GITHUB_REPOSITORY.git" -- repo
cd repo
git config credential.username "$MIRROR_USER"
git config credential.helper '!f() { echo "password=$MIRROR_TOKEN"; }; f'
git push -f --prune "https://${{ matrix.target.repo }}.git" "refs/heads/*:refs/heads/*" "refs/tags/*:refs/tags/*"

Copilot uses AI. Check for mistakes.
repo: cnb.cool/HMCL-dev/HMCL
user: 'CNB_SYNC_USERNAME'
token: 'CNB_SYNC_TOKEN'
name: Mirror to ${{ matrix.target.name }}
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent repository check condition. The original gitee.yml checked github.repository_owner == 'HMCL-dev' while the new mirror.yml checks github.repository == 'HMCL-dev/HMCL'. The new condition is more restrictive (exact repository match vs owner match). If this change is intentional, it's fine, but if the goal was to preserve the original behavior, consider using github.repository_owner == 'HMCL-dev' to allow mirroring from forks within the same organization.

Copilot uses AI. Check for mistakes.
GIT_CNB_VERSION: '1.1.2'
- name: Update mirror repositories
if: ${{ env.continue == 'true' }}
uses: ./.github/workflows/mirror.yml
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uses syntax is incorrect for calling a reusable workflow. The correct syntax should be uses: ./.github/workflows/mirror.yml@${{ github.ref }} or simply reference it without the local path prefix when calling from the same repository. However, since this is a local workflow file in the same repository, you should use the relative path without the ./ prefix: uses: .github/workflows/mirror.yml

Suggested change
uses: ./.github/workflows/mirror.yml
uses: .github/workflows/mirror.yml

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit 9ec4946 into HMCL-dev:main Dec 19, 2025
1 check passed
@Glavo Glavo deleted the cnb branch December 19, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants