github将文件从一个仓库复制到另一个仓库的动作 [英] github action to copy a file from one repo to another

查看:103
本文介绍了github将文件从一个仓库复制到另一个仓库的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司创建了一种在环境之间移动文件的复杂方法,现在我们希望将某些已构建的JS文件(已编译和缩小的文件)从一个github存储库移动到另一个github存储库.使用github动作可以做到这一点吗?

my company has created a complex way to move files between environments and now we would like to move certain built JS files (transpiled and minified) from one github repo to another. Is this possible using github actions?

推荐答案

最简单的选择是克隆目标存储库,将文件复制到目标存储库,使用git命令行暂存文件,然后提交它们.在脚本步骤中添加以下代码

The simplest option is to clone the target repo, copy the files into the target repo, use the git commandline to stage the files and then commit them. Add the code below in a script step

run: |
    git clone https://.:${{ secrets.GITHUB_TOKEN }}@github.com/project target
    rm everything but the .git directory
    copy source\files target
    cd target
    git add .
    git diff-index --quiet HEAD || git commit -m "Automatic publish from github.com/project"
    git push target master

这篇关于github将文件从一个仓库复制到另一个仓库的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆