我希望我的仓库具有2个功能:
两者都需要在仓库中有一个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 }}
答案 0 :(得分:1)
两者都需要在仓库中有一个action.yml。如何将它们结合在一起?
您可以将每个操作保留在各自独立的GitHub Action存储库中。
而且,自2020年8月起,将其合并。
请参阅:
GitHub Actions: Composite Run Steps
您现在可以使用Shell脚本创建可重用的动作,甚至可以在同一动作中混合使用多种Shell语言。
您可能有很多shell脚本来自动化许多任务,现在您可以轻松地将它们变成一个动作,并将其重新用于不同的工作流程。有时,只编写Shell脚本要比JavaScript或Docker容易。
现在,您不必担心将其打包在Docker容器中的脚本。以下是如何使用复合运行步骤操作的示例:
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:
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
详细了解 composite run steps ,并访问GitHub Actions community forum进行提问。
答案 1 :(得分:0)
@chenghopan!如果要在同一存储库中包含两个操作,则应将它们放在单独的目录中。
但是,不需要action.yml
文件。
如果您打算在GitHub Marketplace中列出该文件,则仅需要该操作。
如果您在同一存储库中拥有操作,则它们可以具有自己的action.yml
文件以及Dockerfile或节点脚本。这是带有两个dockerfile的示例:
.
├── README.md
├── .github
│ └── workflows
│ └── main.yml
├── action1
│ ├── Dockerfile
│ ├── action.yml
│ └── entrypoint.sh
└── action2
├── Dockerfile
├── action.yml
└── entrypoint.sh
这是同一回购中的工作流程,它调用同一回购中的两个动作:
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
文件放在与操作相同的目录中,这样就可以了!
作为参考,您可以在以下示例中找到代码: