gpt4 book ai didi

github-actions - 如何在一个 repo 中合并两个 action.yml 文件?

转载 作者:行者123 更新时间:2023-12-03 18:28:38 25 4
gpt4 key购买 nike

我希望我的 repo 有两个功能:

  • 在标签推送上创建发布
  • 在 docker 环境中测试我的软件

  • 两者都需要 repo 中的 action.yml。我如何组合它们?
    name: "Upload a Release Asset"
    description: "Upload a release asset to an existing release on your repository"
    author: "Github"
    inputs:
    upload_url:
    description: "The URL for uploading assets to the release"
    required: true
    asset_path:
    description: "The path to the asset you want to upload"
    required: true
    asset_name:
    description: "The name of the asset you want to upload"
    required: true
    asset_content_type:
    description: "The content-type of the asset you want to upload. See the supported Media Types here: https://www.iana.org/assignments/media-types/media-types.xhtml for more information"
    required: true
    outputs:
    browser_download_url:
    description: "The URL users can navigate to in order to download the uploaded asset"
    runs:
    using: "node12"
    main: "dist/index.js"
    branding:
    icon: "package"
    color: "gray-dark"
    name: 'Hello World'
    description: 'Greet someone and record the time'
    inputs:
    who-to-greet: # id of input
    description: 'Who to greet'
    required: true
    default: 'World'
    outputs:
    time: # id of output
    description: 'The time we greeted you'
    runs:
    using: 'docker'
    image: 'Dockerfile'
    args:
    - ${{ inputs.who-to-greet }}

    最佳答案

    @成和潘!如果您想在同一个存储库中有两个操作,它们应该位于不同的目录中。

    但是,action.yml 文件不是必需的。

    如果您计划在 GitHub Marketplace 中列出某个操作,则该文件仅需要该文件。

    如果您在同一个 repo 中有这些操作,则它们可以拥有自己的 action.yml 文件以及它们的 Dockerfile 或节点脚本。这是一个包含两个 dockerfile 的示例:

    .
    ├── README.md
    ├── .github
    │ └── workflows
    │ └── main.yml
    ├── action1
    │ ├── Dockerfile
    │ ├── action.yml
    │ └── entrypoint.sh
    └── action2
    ├── Dockerfile
    ├── action.yml
    └── entrypoint.sh

    这是同一个 repo 中的一个工作流,调用同一个 repo 中的两个操作:
    name: Test two actions
    on: [push]
    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: ./action1
    - uses: ./action2

    这是另一个调用操作的存储库中的工作流:
    name: Test two actions
    on: [push]
    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - uses: managedkaos/github-actions-two-actions/action1@master
    - uses: managedkaos/github-actions-two-actions/action2@master

    如果您不同意在 GitHub Marketplace 中列出操作,只需将 action.yml 文件放在与操作相同的目录中,就可以了!

    作为引用,您可以在此处找到这些示例中的代码:
  • https://github.com/managedkaos/github-actions-two-actions
  • https://github.com/managedkaos/test-two-actions
  • 关于github-actions - 如何在一个 repo 中合并两个 action.yml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59259783/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com