Nil*_*yan 9 github github-actions
是否有 github 操作允许我将特定文件夹(例如 dist 和 static)从一个分支复制到同一私有存储库中的另一个分支。我很感激任何帮助。这是尝试使用 Copycat 操作使其工作的方法。
name: Copying static files
on:
push:
branches:
- src # Set a branch name to trigger deployment
jobs:
copy:
runs-on: ubuntu-latest
steps:
- name: Copycat
uses: andstor/copycat-action@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }}
src_path: static.
dst_path: /static/
dst_owner: CompanyX
dst_repo_name: MyRepo
dst_branch: dest
src_branch: src
src_wiki: false
dst_wiki: false
- name: Copycat2
uses: andstor/copycat-action@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }}
src_path: dist.
dst_path: /dist/
dst_owner: CompanyX
dst_repo_name: MyRepo
dst_branch: des
src_branch: src
src_wiki: false
dst_wiki: false
Run Code Online (Sandbox Code Playgroud)
但即使我的个人资料中有个人令牌设置,我也会收到此错误。
致命:无法读取“https://github.com”的密码:没有这样的设备或地址
如果您想提交到同一个存储库,则不必指定个人令牌,只需使用actions/checkout@v2(请参阅此)
在分支之间复制文件的一种解决方案是使用git checkout [branch] -- $files,请参阅这篇文章
以下工作流程将文件从static源分支上名为 的目录复制到名为 的分支dest:
name: Copy folder to other branch
on: [push]
jobs:
copy:
name: Copy my folder
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: copy
env:
SRC_FOLDER_PATH: 'static'
TARGET_BRANCH: 'dest'
run: |
files=$(find $SRC_FOLDER_PATH -type f) # get the file list
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git fetch # fetch branches
git checkout $TARGET_BRANCH # checkout to your branch
git checkout ${GITHUB_REF##*/} -- $files # copy files from the source branch
git add -A
git diff-index --quiet HEAD || git commit -am "deploy files" # commit to the repository (ignore if no modification)
git push origin $TARGET_BRANCH # push to remote branch
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5641 次 |
| 最近记录: |