Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cd63ec344 | ||
|
|
32e3e5ab6a | ||
|
|
e8d1c67284 | ||
|
|
fca40d5fe6 | ||
|
|
1d5aeada27 | ||
|
|
cff4df74be | ||
|
|
1e284f150e | ||
|
|
07b07c8cd2 | ||
|
|
9ad56b3196 |
73
README.md
73
README.md
@@ -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"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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`"
|
||||||
|
|||||||
Reference in New Issue
Block a user