5 Commits
v1 ... develop

Author SHA1 Message Date
Abdud Dayan Adeeb
940e86ea21 fixes 2020-06-17 20:50:44 -04:00
Abdud Dayan Adeeb
b1bd71bac3 fixes 2020-06-17 20:39:10 -04:00
Abdud Dayan Adeeb
cf18d277e1 fix: semicolon delimited script 2020-06-17 20:36:04 -04:00
Abdud Dayan Adeeb
a0a75b001b debug multiline 2020-06-17 20:18:29 -04:00
Abdud Dayan Adeeb
d94e0f37db debug 2020-06-17 19:15:51 -04:00
3 changed files with 28 additions and 59 deletions

View File

@@ -1,64 +1,37 @@
# Docker Run Action # 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? 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.
- 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
#### single-line command #### Standard use-case
```yaml ```yaml
- uses: addnab/docker-run-action@v1 - uses: addnab/docker-run-action@v1
with: with:
image: docker:latest image: docker:latest
run: echo "hello world" command: echo "hello world"
``` ```
#### multi-line commands ### Supported Inputs
```yaml ```yaml
- uses: addnab/docker-run-action@v1 image:
with: description: 'Image'
image: docker:latest required: true
run: | options:
echo "first line" description: 'Options'
echo "second line" required: false
``` command:
description: 'Command'
#### run on a privately-owned image required: false
```yaml registry:
- uses: addnab/docker-run-action@v1 description: 'Registry'
with: required: false
username: ${{ secrets.DOCKER_USERNAME }} username:
password: ${{ secrets.DOCKER_PASSWORD }} description: 'Username'
registry: gcr.io required: false
image: test-image:latest password:
run: echo "hello world" description: 'Password'
``` 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,13 +8,9 @@ inputs:
options: options:
description: 'Options' description: 'Options'
required: false required: false
run: command:
description: 'Run command in container' description: 'Command'
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,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ ! -z $INPUT_USERNAME ]; 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 fi
echo "$INPUT_RUN" | sed -e 's/\\n/;/g' > semicolon_delimited_script echo "$INPUT_COMMAND" | 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`" exec docker run $INPUT_OPTIONS $INPUT_IMAGE /bin/sh -c "`cat semicolon_delimited_script`"