From 7444b2b5ac1e9689f7a837940ad225ac534e3b5e Mon Sep 17 00:00:00 2001 From: Abdud Dayan Adeeb Date: Wed, 17 Jun 2020 18:47:31 -0400 Subject: [PATCH] setup docker run action --- .gitignore | 1 + Dockerfile | 5 +++++ README.md | 40 ++++++++++++++++++++++++++++++++++++++++ action.yml | 28 ++++++++++++++++++++++++++++ entrypoint.sh | 7 +++++++ 5 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b59c49a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM docker:19.03 + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..265c580 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Docker Run Action + +This action targets a very specific use-case that is not currently supported by Github Workflows. This action gives you the capability to run built containers. + +Docker already supports running commands inside a docker image. See [jobs..container](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer). But it doesn't give you a clean way to run an image from a private repo or an image built on a previous step. + +### Example Usage + +#### Standard use-case +```yaml +- uses: addnab/docker-run-action@v1 + with: + image: docker:latest + command: echo "hello world" +``` + +### Supported Inputs +```yaml + image: + description: 'Image' + required: true + options: + description: 'Options' + required: false + command: + description: 'Command' + required: false + args: + description: 'Args' + required: false + registry: + description: 'Registry' + required: false + username: + description: 'Username' + required: false + password: + description: 'Password' + required: false +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..ade7c6e --- /dev/null +++ b/action.yml @@ -0,0 +1,28 @@ +# action.yml +name: 'Docker Run Action' +description: 'Run a command in a new container' +inputs: + image: + description: 'Image' + required: true + options: + description: 'Options' + required: false + command: + description: 'Command' + required: false + args: + description: 'Args' + required: false + registry: + description: 'Registry' + required: false + username: + description: 'Username' + required: false + password: + description: 'Password' + required: false +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..24664a9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ ! -z $INPUT_USERNAME ]; +then echo $INPUT_USERNAME | docker login $INPUT_REGISTRY -u $INPUT_PASSWORD --password-stdin +fi + +exec docker run $INPUT_OPTIONS $INPUT_IMAGE $INPUT_COMMAND $INPUT_ARGS