mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-18 01:26:37 +08:00
fix: fix secrets
This commit is contained in:
parent
47e6eb1bcd
commit
8122fe74fb
54
.github/workflows/sync-upstream.yml
vendored
Normal file
54
.github/workflows/sync-upstream.yml
vendored
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
8
.github/workflows/sync-upstreem-pr.yml
vendored
8
.github/workflows/sync-upstreem-pr.yml
vendored
@ -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: |
|
||||||
|
Loading…
Reference in New Issue
Block a user