9 Commits
debug ... v1

Author SHA1 Message Date
1cd63ec344 fix: exposing docker socket for DinD 2020-06-24 15:16:56 -04:00
32e3e5ab6a Update README.md 2020-06-19 20:36:37 -04:00
e8d1c67284 fix login 2020-06-17 22:21:03 -04:00
fca40d5fe6 override entrypoint 2020-06-17 21:53:32 -04:00
1d5aeada27 docs for privately owned image 2020-06-17 21:39:34 -04:00
cff4df74be run on specific shell 2020-06-17 21:21:47 -04:00
1e284f150e fix run variable name 2020-06-17 21:04:51 -04:00
07b07c8cd2 update README 2020-06-17 21:02:26 -04:00
9ad56b3196 multiline support 2020-06-17 21:00:26 -04:00
3 changed files with 60 additions and 27 deletions

View File

@ -1,37 +1,64 @@
# 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.
Github Workflows already supports running on public docker images out-of-the-box (See [jobs.<jobs_id>.container](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer)).
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.
### Why use docker-run-action?
- run on a privately-owned image.
- run on an image built by a previous step.
- run a specific step in docker
### Example Usage
#### Standard use-case
#### single-line command
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
command: echo "hello world"
run: echo "hello world"
```
### Supported Inputs
#### multi-line commands
```yaml
image:
description: 'Image'
required: true
options:
description: 'Options'
required: false
command:
description: 'Command'
required: false
registry:
description: 'Registry'
required: false
username:
description: 'Username'
required: false
password:
description: 'Password'
required: false
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
run: |
echo "first line"
echo "second line"
```
#### run on a privately-owned image
```yaml
- uses: addnab/docker-run-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: gcr.io
image: test-image:latest
run: echo "hello world"
```
#### run on an image built by a previous step
```yaml
- uses: docker/build-push-action@v1
with:
repository: test-image
push: false
- uses: addnab/docker-run-action@v1
with:
image: test-image:latest
run: echo "hello world"
```
#### use a specific shell (default: sh).
*Note: The shell must be installed in the container*
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
shell: bash
run: |
echo "first line"
echo "second line"
```

View File

@ -8,9 +8,13 @@ inputs:
options:
description: 'Options'
required: false
command:
description: 'Command'
run:
description: 'Run command in container'
required: false
shell:
description: 'Use a specific shell'
required: false
default: sh
registry:
description: 'Registry'
required: false

View File

@ -1,7 +1,9 @@
#!/usr/bin/env bash
if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_USERNAME | docker login $INPUT_REGISTRY -u $INPUT_PASSWORD --password-stdin
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
fi
exec docker run $INPUT_OPTIONS $INPUT_IMAGE $INPUT_COMMAND
echo "$INPUT_RUN" | sed -e 's/\\n/;/g' > semicolon_delimited_script
exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "`cat semicolon_delimited_script`"