This repository has been archived on 2024-09-20. You can view files and clone it, but cannot push or open issues or pull requests.
docker-run-action/README.md

75 lines
1.6 KiB
Markdown
Raw Normal View History

2020-06-18 00:47:31 +02:00
# Docker Run Action
2020-06-18 03:39:34 +02:00
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)).
2020-06-18 00:47:31 +02:00
2020-06-18 03:39:34 +02:00
### Why use docker-run-action?
- run on a privately-owned image.
- run on an image built by a previous step.
2020-06-20 02:36:37 +02:00
- run a specific step in docker
2020-06-18 00:47:31 +02:00
### Example Usage
2020-06-18 03:21:47 +02:00
#### single-line command
2020-06-18 00:47:31 +02:00
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
2020-06-18 03:00:26 +02:00
run: echo "hello world"
```
2020-06-18 03:21:47 +02:00
#### multi-line commands
2020-06-18 03:00:26 +02:00
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
run: |
echo "first line"
echo "second line"
2020-06-18 00:47:31 +02:00
```
2020-06-18 03:21:47 +02:00
2020-06-18 03:39:34 +02:00
#### 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
2020-06-18 03:21:47 +02:00
```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).
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
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
shell: bash
run: |
echo "first line"
echo "second line"
```
2021-01-04 21:53:19 +01:00
### use docker options
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
options: -v $GITHUB_WORKSPACE:/work -e ABC=123
run: |
echo "first line"
```