公司已经开发了一种复杂的方法在环境之间移动文件,现在我们希望将某些已构建的JS文件(经过转译和缩小)从一个Github存储库移动到另一个存储库。使用Github Actions是否可以实现这一点?
最简单的方法是克隆目标仓库,将文件复制到目标仓库中,使用git命令行暂存这些文件,然后提交它们。在脚本步骤中添加以下代码:
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
git commit
行以处理没有更改的情况。否则,该操作将失败。git diff-index --quiet HEAD || git commit
。创意来源:github.com/cpina此外,上面的网址正确吗?“//:。”是什么? - Robert Lugg.
是用户名(在使用令牌时无关紧要)。在 :
后面是密码(令牌)。如果您愿意,可以使用 notneeded:
或 github:
。 - jessehouwing