Files
license-manager/.github/workflows/sync_to_enterprise.yml
T

62 lines
1.9 KiB
YAML

name: Sync to Enterprise
on:
push:
branches:
- main
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Debug info
env:
TOKEN: ${{ secrets.ENTERPRISE_REPO_TOKEN }}
run: |
echo "=== Debug Info ==="
echo "Token prefix: ${TOKEN:0:10}"
# 用 gh API 检查仓库是否存在
echo "Checking repo via API..."
curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/cedar-v/license-manager-enterprise" | head -20
echo ""
echo "Checking user repos..."
curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/user/repos?per_page=100" | grep -o '"full_name":"[^"]*license-manager[^"]*"' || echo "No matching repo found"
- name: Sync to enterprise repo
env:
TOKEN: ${{ secrets.ENTERPRISE_REPO_TOKEN }}
run: |
# 直接用认证 URL clone 和 push
REPO_URL="https://x-access-token:$TOKEN@github.com/cedar-v/license-manager-enterprise.git"
echo "Cloning enterprise repo..."
git clone "$REPO_URL" /tmp/enterprise-repo || {
echo "Clone failed!"
exit 1
}
cd /tmp/enterprise-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
echo "Copying files..."
cd "$GITHUB_WORKSPACE"
cp -r . /tmp/enterprise-repo/
cd /tmp/enterprise-repo
git add -A
git commit -m "Sync from license-manager - $(date)" || echo "Nothing to commit"
git push origin master --force
echo "Done!"