1 Commits
v1 ... debug

Author SHA1 Message Date
Abdud Dayan Adeeb
d94e0f37db debug 2020-06-17 19:15:51 -04:00
3 changed files with 29 additions and 60 deletions

View File

@@ -1,64 +1,37 @@
# Docker Run Action
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)).
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.
### 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
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
#### single-line command
#### Standard use-case
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
run: echo "hello world"
command: echo "hello world"
```
#### multi-line commands
### Supported Inputs
```yaml
- 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"
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
```

View File

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

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash
if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
then echo $INPUT_USERNAME | docker login $INPUT_REGISTRY -u $INPUT_PASSWORD --password-stdin
fi
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`"
echo $INPUT_COMMAND
echo "running"
exec docker run $INPUT_OPTIONS $INPUT_IMAGE $INPUT_COMMAND