GitHub Actions 可以从私有存储库创建到公共存储库的发布吗?

sin*_*ity 6 github-actions

我想创建一个包含可供用户下载的资源的版本。由于它是一个私人存储库,因此我想在单独的公共存储库中创建该版本。这在 GitHub Actions 中可行吗?

create-release操作中有ownerrepo参数,但将它们设置为不同的存储库后我不断收到错误:

   - name: Create Release
     id: create_release
     uses: actions/create-release@v1
     env:
       GITHUB_TOKEN: ${{ secrets.PAT }} # A personal access token
     with:
       tag_name: ${{ github.ref }}
       release_name: Release ${{ github.ref }}
       draft: false
       prerelease: false
       owner: foo
       repo: another_public_repo
Run Code Online (Sandbox Code Playgroud)

错误:验证失败:{"resource":"Release","code":"custom","field":"tag_name","message":"tag_name 不是有效标签"}, {"resource":" Release","code":"custom","message":"发布的版本必须具有有效的标签"}, {"resource":"Release","code":"invalid","field":"target_commitish" }

riQ*_*iQQ 1

您必须在 中指定现有标签tag_name。在您的情况下,这意味着在创建版本之前在公共存储库中创建标签。或者,您可以在 中指定分支或提交 SHA ,如果 中 指定的标签不存在commitish,则使用该分支或提交 SHA 。tag_name

  - name: Checkout public repository
    uses: actions/checkout@v2
    with:
      repository: foo/another_public_repo
      path: another_public_repo
  - name: Get tag name from ref
    shell: bash
    run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
    id: get_tag
  - name: Create tag in public repository
    run: |
      cd ${{github.workspace}}/another_public_repo
      git tag ${{ steps.get_tag.outputs.tag }}
      git push --tags --porcelain
  - name: Create Release
    id: create_release
    uses: actions/create-release@v1
    env:
      GITHUB_TOKEN: ${{ secrets.PAT }} # A personal access token
    with:
      tag_name: ${{ steps.get_tag.outputs.tag }}
      release_name: Release ${{ steps.get_tag.outputs.tag }}
      draft: false
      prerelease: false
      owner: foo
      repo: another_public_repo
Run Code Online (Sandbox Code Playgroud)