如何使用actions / checkout @ master将源放入指定的文件夹?

时间:2019-09-12 21:28:32

标签: git github github-actions

我正在尝试在github存储库中实现一些自动化工具,但是我遇到了一些问题。现在,我不明白如何将源文件放入指定的文件夹。

例如,我有2个分支机构

  • 第一个是来源分支
  • 第二个是测试分支

现在,我尝试克隆第一个分支,构建项目(该项目在C ++中),然后克隆第二个分支,构建第二个分支并运行测试。

我可以使用动作/签出功能还是必须使用另一种方法?

如果您对操作/结帐操作的实施方式有所了解,请告诉我。我很感兴趣。

2 个答案:

答案 0 :(得分:0)

我尝试使用actions/checkout@master在同一工作流程中签出两个不同的分支。这是行不通的,因为在第二次运行时,第一个签出源会自动删除,并显示以下消息:

Repository is current at '/home/runner/work/actions-playground/actions-playground', move to '/home/runner/work/actions-playground/actions-playground/test-sources'.
Repository will locate at '/home/runner/work/actions-playground/actions-playground/test-sources'.

我不确定是否有更好的解决方案,但是以下方法对我有用。此解决方案使用范围为repo的令牌手动检出第二个分支。在https://github.com/settings/tokens创建一个,然后作为秘密添加到您的存储库。它将位于https://github.com/[username]/[repo]/settings/secrets

test-branch被检出到主存储库根目录的test-sources目录中。

name: my workflow
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Checkout tests
      env:
        REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
      run: git clone -b test-branch https://$REPO_ACCESS_TOKEN:x-oauth-basic@github.com/[username]/[repo].git test-sources

答案 1 :(得分:0)

使用“路径”参数。请参阅https://github.com/actions/checkout

中的“签出多个存储库”