fix: fix secrets

This commit is contained in:
sagitchu 2025-03-18 16:29:27 +08:00
parent 47e6eb1bcd
commit 8122fe74fb
2 changed files with 58 additions and 4 deletions

54
.github/workflows/sync-upstream.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Sync Upstream PRs
on:
schedule:
- cron: '0 */6 * * *' # 每6小时运行一次
workflow_dispatch: # 允许手动触发
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Sync upstream pull requests
uses: actions/github-script@v6
with:
github-token: ${{ secrets.sync.TOKEN }}
script: |
const upstream = 'upstream-owner/upstream-repo'; // 替换为实际的上游仓库
const [owner, repo] = upstream.split('/');
// 获取上游仓库的PR
const pulls = await github.rest.pulls.list({
owner,
repo,
state: 'open'
});
// 为每个PR创建或更新对应的PR
for (const pull of pulls.data) {
try {
// 检查是否已存在相同的PR
const existingPulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${owner}:${pull.head.ref}`,
});
if (existingPulls.data.length === 0) {
// 创建新的PR
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `[Upstream] ${pull.title}`,
body: `Synced from upstream PR: ${pull.html_url}\n\n${pull.body || ''}`,
head: `${owner}:${pull.head.ref}`,
base: pull.base.ref,
});
}
} catch (error) {
console.log(`Error processing PR #${pull.number}: ${error.message}`);
}
}

View File

@ -23,11 +23,11 @@ jobs:
- name: Sync Upstream PRs - name: Sync Upstream PRs
env: env:
# GITHUB_TOKEN: ${{ secrets.TOKEN }} GITHUB_TOKEN: ${{ secrets.sync.TOKEN }}
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
UPSTREAM_REPO: ${{ secrets.UPSTREAM_REPO }} # 例如 'original-owner/original-repo' UPSTREAM_REPO: ${{ secrets.sync.UPSTREAM_REPO }} # 例如 'original-owner/original-repo'
UPSTREAM_OWNER: ${{ secrets.UPSTREAM_OWNER }} # 例如 'original-owner' UPSTREAM_OWNER: ${{ secrets.sync.UPSTREAM_OWNER }} # 例如 'original-owner'
UPSTREAM_REPO_NAME: ${{ secrets.UPSTREAM_REPO_NAME }} # 例如 'original-repo' UPSTREAM_REPO_NAME: ${{ secrets.sync.UPSTREAM_REPO_NAME }} # 例如 'original-repo'
REPO_OWNER: ${{ github.repository_owner }} REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }} REPO_NAME: ${{ github.event.repository.name }}
run: | run: |