Title here
Summary here
自动同步来源: NEVSTOP-LAB/Push-Files-to-Repo 导入规则:README 包含不少于 50 个中文字符时导入,正文保持原文。
一个通过 Pull Request 将文件或文件夹从一个仓库推送到另一个仓库的 GitHub Action。
name: 推送文件到另一个仓库
on:
push:
branches: [main]
jobs:
push-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'docs/'
destination_repo: 'my-org/my-other-repo'
destination_folder: 'imported-docs/'
token: ${{ secrets.PAT }}| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
source_folder | ✅ | – | 源文件或文件夹路径(相对于仓库根目录) |
destination_repo | ✅ | – | 目标仓库,格式为 owner/repo |
destination_folder | ❌ | . | 目标仓库中的存放路径 |
destination_base_branch | ❌ | main | 创建 PR 的目标基础分支 |
destination_head_branch | ❌ | 自动生成 | PR 的分支名称 |
token | ✅ | – | 具有目标仓库访问权限的 PAT 或 GitHub App Token |
commit_message | ❌ | chore: push files from source repository | 提交信息 |
pr_title | ❌ | [Automated] Push files from source repository | PR 标题 |
pr_body | ❌ | 自动生成 | PR 描述 |
git_user_name | ❌ | github-actions[bot] | Git 提交者名称 |
git_user_email | ❌ | 41898282+github-actions[bot]@users.noreply.github.com | Git 提交者邮箱 |
cleanup | ❌ | false | 复制前是否删除目标文件夹中的已有文件 |
draft | ❌ | false | 是否创建草稿 PR |
| 输出 | 说明 |
|---|---|
pr_number | 创建的 Pull Request 编号 |
pr_url | 创建的 Pull Request URL |
此 Action 需要一个具有目标仓库访问权限的 Token。默认的 GITHUB_TOKEN 仅能访问当前仓库,无法用于跨仓库操作。
Contents:Read and writePull requests:Read and writePAT)Contents:Read and writePull requests:Read and write- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: target-owner
repositories: target-repo
- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'dist/'
destination_repo: 'target-owner/target-repo'
token: ${{ steps.app-token.outputs.token }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'build/output'
destination_repo: 'my-org/website'
destination_folder: 'static/assets'
token: ${{ secrets.PAT }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'config/settings.json'
destination_repo: 'my-org/config-repo'
destination_folder: 'apps/myapp'
token: ${{ secrets.PAT }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'generated-docs/'
destination_repo: 'my-org/docs-repo'
destination_folder: 'api-docs/'
cleanup: 'true'
token: ${{ secrets.PAT }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'src/shared'
destination_repo: 'my-org/shared-lib'
destination_folder: 'src'
commit_message: 'feat: sync shared components from main repo'
pr_title: 'Sync shared components'
pr_body: |
Automated sync of shared components.
Source: ${{ github.repository }}@${{ github.sha }}
token: ${{ secrets.PAT }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
with:
source_folder: 'dist/'
destination_repo: 'my-org/release-repo'
draft: 'true'
token: ${{ secrets.PAT }}- uses: NEVSTOP-LAB/Push-Files-to-Repo@main
id: push
with:
source_folder: 'docs/'
destination_repo: 'my-org/docs'
token: ${{ secrets.PAT }}
- run: |
echo "PR #${{ steps.push.outputs.pr_number }}"
echo "URL: ${{ steps.push.outputs.pr_url }}"详细的研究和设计文档请参阅 docs/design.md,包括:
MIT