How do you write a Docker container action and pass inputs to it?
IntermediateConceptCustom Actions & Reusable Workflows
Answer
# action.yml
name: Kubeconform
inputs:
path: { description: Manifests dir, default: k8s }
runs:
using: docker
image: Dockerfile # or docker://ghcr.io/org/kubeconform-action:1.2.0
args:
- ${{ inputs.path }}
FROM ghcr.io/yannh/kubeconform:v0.6.7-alpine
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Inputs also arrive as env vars INPUT_PATH. The workspace is mounted at /github/workspace. Prefer a prebuilt published image over Dockerfile so consumers do not rebuild it every run.
More on Custom Actions & Reusable Workflows
What are the three kinds of custom action and how do you choose?BeginnerWrite a minimal composite action that installs Node and dependencies with caching.IntermediateWhat can a composite action not do compared to a job?IntermediateHow do you pass outputs out of a composite action?IntermediateWhat does `action.yml` contain for a JavaScript action?IntermediateWhy must a JavaScript action commit its `dist/` or `node_modules`?Intermediate