Skip to content

Commit

Permalink
setup docker run action
Browse files Browse the repository at this point in the history
  • Loading branch information
addnab committed Jun 17, 2020
1 parent b5d56dc commit 7444b2b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM docker:19.03

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.<jobs_id>.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
```
28 changes: 28 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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'
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7444b2b

Please sign in to comment.