9 Commits
debug ... v1

Author SHA1 Message Date
Abdud Dayan Adeeb
1cd63ec344 fix: exposing docker socket for DinD 2020-06-24 15:16:56 -04:00
Abdud Dayan Adeeb
32e3e5ab6a Update README.md 2020-06-19 20:36:37 -04:00
Abdud Dayan Adeeb
e8d1c67284 fix login 2020-06-17 22:21:03 -04:00
Abdud Dayan Adeeb
fca40d5fe6 override entrypoint 2020-06-17 21:53:32 -04:00
Abdud Dayan Adeeb
1d5aeada27 docs for privately owned image 2020-06-17 21:39:34 -04:00
Abdud Dayan Adeeb
cff4df74be run on specific shell 2020-06-17 21:21:47 -04:00
Abdud Dayan Adeeb
1e284f150e fix run variable name 2020-06-17 21:04:51 -04:00
Abdud Dayan Adeeb
07b07c8cd2 update README 2020-06-17 21:02:26 -04:00
Abdud Dayan Adeeb
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 # 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 ### Example Usage
#### Standard use-case #### single-line command
```yaml ```yaml
- uses: addnab/docker-run-action@v1 - uses: addnab/docker-run-action@v1
with: with:
image: docker:latest image: docker:latest
command: echo "hello world" run: echo "hello world"
``` ```
### Supported Inputs #### multi-line commands
```yaml ```yaml
image: - uses: addnab/docker-run-action@v1
description: 'Image' with:
required: true image: docker:latest
options: run: |
description: 'Options' echo "first line"
required: false echo "second line"
command: ```
description: 'Command'
required: false #### run on a privately-owned image
registry: ```yaml
description: 'Registry' - uses: addnab/docker-run-action@v1
required: false with:
username: username: ${{ secrets.DOCKER_USERNAME }}
description: 'Username' password: ${{ secrets.DOCKER_PASSWORD }}
required: false registry: gcr.io
password: image: test-image:latest
description: 'Password' run: echo "hello world"
required: false ```
#### 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: options:
description: 'Options' description: 'Options'
required: false required: false
command: run:
description: 'Command' description: 'Run command in container'
required: false required: false
shell:
description: 'Use a specific shell'
required: false
default: sh
registry: registry:
description: 'Registry' description: 'Registry'
required: false required: false

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ ! -z $INPUT_USERNAME ]; 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 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`"