github-actions - GitHub Actions 可以从私有(private)仓库创建到公共(public)仓库的发布吗?

标签 github-actions

我想创建一个包含供用户下载的 Assets 的版本。由于它是一个私有(private)仓库,我想在一个单独的公共(public)仓库中创建发布。这在 GitHub Actions 中可行吗?

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

   - 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

Error: Validation Failed: {"resource":"Release","code":"custom","field":"tag_name","message":"tag_name is not a valid tag"}, {"resource":"Release","code":"custom","message":"Published releases must have a valid tag"}, {"resource":"Release","code":"invalid","field":"target_commitish"}

最佳答案

您要么必须在 tag_name 中指定一个现有标签。在您的情况下,这意味着在创建发布之前在公共(public)存储库中创建标签。或者您可以在 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

关于github-actions - GitHub Actions 可以从私有(private)仓库创建到公共(public)仓库的发布吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64958538/

相关文章:

c++ - 由于找不到conanfile.py,使用CMake,conan和Vulkan SDK的Github操作失败

python - 使用来自 github-actions 的 python-coveralls 返回 "Could not submit coverage: 422 Client Error"

github - 跨作业重用 github 操作的一部分

github - 复合运行步骤 GitHub 操作错误 : 'An action could not be found at the URI'

docker - 当我们想通过github操作执行ansible命令时如何管理ssh key 文件

python - 在 Google Colab 中编辑 README.md 文件

github-actions - 如何使用 GITHUB-SHA 在 workflow_dispatch Github 操作中预填充输入字段

node.js - Github Action err : bash: line 3: npm: command not found

GitHub 操作 : Are there security concerns using an external action in a workflow job?

github - 无法建立 SSL 连接,在配置 Github Self-Hosted Runner 时查看内部​​异常