2020-06-18 00:47:31 +02:00
|
|
|
# Docker Run Action
|
|
|
|
|
2021-02-15 07:12:38 +01:00
|
|
|
- run a specific step in docker.
|
2021-02-15 22:21:09 +01:00
|
|
|
- run an image built by a previous step.
|
2021-02-15 07:12:38 +01:00
|
|
|
- See https://github.com/addnab/docker-run-action/blob/main/action.yml for all the available inputs.
|
2020-06-18 00:47:31 +02:00
|
|
|
|
2021-03-18 01:49:17 +01:00
|
|
|
## Examples
|
|
|
|
|
2021-02-15 07:12:38 +01:00
|
|
|
#### Typical Use Case
|
2020-06-18 00:47:31 +02:00
|
|
|
|
2020-06-18 03:00:26 +02:00
|
|
|
```yaml
|
2021-05-30 20:48:01 +02:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume
|
2021-03-18 01:49:17 +01:00
|
|
|
- uses: addnab/docker-run-action@v3
|
2020-06-18 03:00:26 +02:00
|
|
|
with:
|
2021-02-15 07:12:38 +01:00
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
registry: gcr.io
|
|
|
|
image: private-image:latest
|
2021-07-09 10:33:42 +02:00
|
|
|
options: -e ABC=123
|
2020-06-18 03:00:26 +02:00
|
|
|
run: |
|
2021-02-15 07:27:21 +01:00
|
|
|
echo "Running Script"
|
|
|
|
/work/run-script
|
2020-06-18 00:47:31 +02:00
|
|
|
```
|
2020-06-18 03:21:47 +02:00
|
|
|
|
2021-02-15 07:12:38 +01:00
|
|
|
#### run a privately-owned image
|
2020-06-18 03:39:34 +02:00
|
|
|
```yaml
|
2021-03-18 01:49:17 +01:00
|
|
|
- uses: addnab/docker-run-action@v3
|
2020-06-18 03:39:34 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
registry: gcr.io
|
|
|
|
image: test-image:latest
|
|
|
|
run: echo "hello world"
|
|
|
|
```
|
|
|
|
|
2021-02-15 07:12:38 +01:00
|
|
|
#### run an image built by a previous step
|
2020-06-18 03:21:47 +02:00
|
|
|
```yaml
|
2021-03-22 03:12:44 +01:00
|
|
|
- uses: docker/build-push-action@v2
|
2020-06-18 03:21:47 +02:00
|
|
|
with:
|
2021-03-22 03:12:44 +01:00
|
|
|
tags: test-image:latest
|
2020-06-18 03:21:47 +02:00
|
|
|
push: false
|
2021-03-18 01:49:17 +01:00
|
|
|
- uses: addnab/docker-run-action@v3
|
2020-06-18 03:21:47 +02:00
|
|
|
with:
|
|
|
|
image: test-image:latest
|
|
|
|
run: echo "hello world"
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### use a specific shell (default: sh).
|
2020-06-18 03:39:34 +02:00
|
|
|
*Note: The shell must be installed in the container*
|
2020-06-18 03:21:47 +02:00
|
|
|
```yaml
|
2021-03-18 01:49:17 +01:00
|
|
|
- uses: addnab/docker-run-action@v3
|
2020-06-18 03:21:47 +02:00
|
|
|
with:
|
|
|
|
image: docker:latest
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "first line"
|
|
|
|
echo "second line"
|
|
|
|
```
|