如何在一个仓库中合并两个action.yml文件? [英] How to combine two action.yml files in one repo?

查看:124
本文介绍了如何在一个仓库中合并两个action.yml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的仓库具有2个功能:

I would like my repo to have 2 functions:

  1. 通过标签推送创建发布
  2. 在docker环境中测试我的软件

两者都需要在仓库中有一个action.yml.如何将它们结合在一起?

Both require an action.yml in the repo. How do I combine them?

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.如何将它们结合在一起?

Both require an action.yml in the repo. How do I combine them?

您可以将每个操作保留在各自独立的GitHub Action存储库中.

You could leave each of your actions in their own separate GitHub Action repository.

而且,自2020年8月以来,将它们组合.

And, since August 2020, combine them.

请参阅:

GitHub动作:复合运行步骤

您现在可以使用Shell脚本创建可重用的动作,甚至可以在同一动作中混合使用多种Shell语言.
您可能有很多shell脚本来自动化许多任务,现在您可以轻松地将它们变成一个动作,并将其重新用于不同的工作流程.有时,只编写Shell脚本要比JavaScript或Docker容易.
现在,您不必担心将其打包在Docker容器中的脚本.

GitHub Actions: Composite Run Steps

You can now create reusable actions using shell scripts and even mix multiple shell languages in the same action.
You probably have a lot of shell script to automate many tasks, now you can easily turn them into an action and reuse them for different workflows. Sometimes it's easier to just write a shell script than JavaScript or Docker.
Now you don't have to worry about wrapping it up your scripts in a Docker containers.

以下是如何使用复合运行步骤操作的示例:

Here's an example of how you can use composite run steps actions:

workflow.yml:

workflow.yml:

jobs:
 build:
   runs-on: windows-latest
   steps:
   - uses: actions/checkout@v2
   - uses: octocat/say-hello@v1
     with: 
       name: OctoCat

octocat/say-hello/action.yml:

octocat/say-hello/action.yml:

inputs:
 name: 
   description: 'Your name'
   default: 'No name provided'
runs:
 using: "composite"
 steps: 
   - run: echo Hello ${{ inputs.name }}.
     shell: bash
   - run: echo "Nice to meet you!"
     shell: pwsh

详细了解 复合运行步骤 ,并访问<一个href ="https://github.community/c/github-actions" rel ="nofollow noreferrer"> GitHub Actions社区论坛以获取问题.

Learn more about composite run steps and visit the GitHub Actions community forum for questions.

这篇关于如何在一个仓库中合并两个action.yml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆