Reputation: 7129
I'm trying to make my first action to build packages inside a given docker container. I have the following action.yaml
file:
name: Build Package
description: Build Debian packages using Docker image
inputs:
docker_image:
description: Name of the docker image to use
required: true
runs:
using: 'composite'
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Build `*.deb` packages
uses: 'docker://${{inputs.docker_image}}'
with:
entrypoint: ./build.sh
In the other repository I'm trying to use it:
...
steps:
- uses: CMakeify-me/build-package-action@v1-beta
with:
docker_image: 'cmakeifyme/debian-9-deb-build:1.3'
Unfortunately, I've got the error:
Error: CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13):
Error: CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.docker_image
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.docker_image
at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load CMakeify-me/build-package-action/v1-beta/action.yaml
Trying just print the inputs
works fine:
- name: Spam
run: echo '${{ inputs.docker_image }}'
shell: bash
Meaning, that there is some problem when inputs.docker_image
is used within the value of uses:
;-(
How can I pass the docker image name to be used in my action?
Thank you.
Upvotes: 2
Views: 876
Reputation: 1390
I don't think you can't use an input/variable with uses
like that.
This is not explicitly mentioned in the documentation but you can see a warning here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
If you need to dynamically pick your docker container, you might have to look into an alternative. You can avoid uses
and run docker from shell directly, like this...
Call your action, and pass the input via with
:
- uses: CMakeify-me/build-package-action@v1-beta
with:
docker_image: 'cmakeifyme/debian-9-deb-build:1.3'
Then your action can us the input via run
, using shell
to call docker:
- name: run docker with dynamic image name
run: 'docker run ${{ inputs.docker_image }}'
shell: bash
Upvotes: 2