36 Commits
v1 ... main

Author SHA1 Message Date
Brock Allen
84aec248fc fix: print tarball path before loading 2024-03-03 22:14:39 -08:00
Brock Allen
f325c05afe wip: testing tarball field 2024-02-02 17:27:24 -08:00
Brock Allen
7fff0e1b7b feat: support docker image tarballs 2024-02-02 17:13:04 -08:00
Abdud Dayan Adeeb
3e77f186b7 Merge pull request #18 from rlancer/main
Updated docs
2021-05-30 16:29:20 -04:00
Robert Lancer
e6b2dcfc59 Updated docs
Demonstrates the need to checkout in order to mount a volume
2021-05-30 14:48:01 -04:00
Abdud Dayan Adeeb
358af5c600 Merge pull request #17 from lextira/bugfix/remove-command-file
Remove temporary "semicolon_delimited_script"
2021-04-07 16:56:13 -04:00
Dominik Kohler
fe7c510b59 use bash "shell parameter expansion" 2021-04-07 14:41:21 +02:00
Abdud Dayan Adeeb
43383a67d7 docs: example with latest docker build action
Closes #13
2021-03-21 22:12:44 -04:00
Abdud Dayan Adeeb
a808c5419d docs: update to v3 2021-03-17 20:49:17 -04:00
Abdud Dayan Adeeb
3b7e5e2681 Update RELEASES.md 2021-03-17 13:00:15 -04:00
Abdud Dayan Adeeb
4f65fabd24 Merge pull request #12 from rossettistone/docker-upgrade
Upgrade to more recent image of Docker
2021-03-17 10:43:43 -04:00
Mark Rossetti
7485e8fe25 Upgrade to more recent image of Docker 2021-03-16 10:40:17 -04:00
Abdud Dayan Adeeb
29813b1169 Merge pull request #8 from mdpye/patch-1
fix: typo in required field of action metadata
2021-03-03 18:01:38 -05:00
Mike Pye
3de7aa4662 fix: typo in required field of action metadata 2021-02-26 17:51:48 +00:00
Abdud Dayan Adeeb
4d955dc997 feat: upgrade to v2 2021-02-15 17:26:10 -05:00
Abdud Dayan Adeeb
e7a9a2b25a Merge pull request #7 from addnab/tests
tests: setup tests
2021-02-15 17:15:51 -05:00
Abdud Dayan Adeeb
8279676ac5 test: add container network test 2021-02-15 17:13:07 -05:00
Abdud Dayan Adeeb
a34de16206 test: adding volume mount test 2021-02-15 16:52:12 -05:00
Abdud Dayan Adeeb
f9c1c286e0 test: test docker version 2021-02-15 16:45:41 -05:00
Abdud Dayan Adeeb
f451fad679 fix: check if network exists 2021-02-15 16:21:09 -05:00
Abdud Dayan Adeeb
6321bad333 fix: remove unused workflow 2021-02-15 15:59:37 -05:00
Abdud Dayan Adeeb
4b731f3709 tests: setup tests 2021-02-15 15:58:29 -05:00
Abdud Dayan Adeeb
6f0804dd49 docs: using github variables instead of env 2021-02-15 09:26:29 -05:00
Abdud Dayan Adeeb
e10bcda95f Update README.md 2021-02-15 01:27:21 -05:00
Abdud Dayan Adeeb
702ff8ec17 Update README.md 2021-02-15 01:12:38 -05:00
Abdud Dayan Adeeb
e48328783a Merge pull request #3 from heyman/docker-networks
Docker networks
2021-02-15 00:49:24 -05:00
Jonatan Heyman
c0e88e3a9a Remove whitespace change 2021-01-28 17:13:38 +01:00
Jonatan Heyman
3cf4359b92 Remove debug logging 2021-01-28 17:01:59 +01:00
Jonatan Heyman
a42f5acd32 Revert "Use env variable for docker network id, instead of github action input"
This reverts commit 23e2be876e.
2021-01-28 17:00:10 +01:00
Jonatan Heyman
23e2be876e Use env variable for docker network id, instead of github action input 2021-01-28 16:54:08 +01:00
Jonatan Heyman
faad629471 Connect container to github job docker network 2021-01-28 16:44:05 +01:00
Jonatan Heyman
8bce4aa10a Add docker_network input 2021-01-28 16:39:33 +01:00
Jonatan Heyman
f3a2d182d8 Debug 2021-01-28 16:22:09 +01:00
Abdud Dayan Adeeb
27808d9e5f Update README.md 2021-01-09 15:29:20 -05:00
Abdud Dayan Adeeb
56a9143b97 Update README.md 2021-01-04 16:09:39 -05:00
Abdud Dayan Adeeb
68f0bc9ea0 docs: options (fixes #1) 2021-01-04 15:54:00 -05:00
6 changed files with 125 additions and 29 deletions

72
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Docker Run Action Tests
on:
push:
branches:
- main
pull_request:
jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run docker action and set output for testing
uses: ./
id: run-docker
with:
image: docker:20.10.3
run: |
echo "::set-output name=docker-version::`echo $DOCKER_VERSION`"
- name: Test the output
uses: actions/github-script@v3
with:
script: |
const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}';
if (dockerVersion !== '20.10.3') {
core.setFailed(`Smoke Test Failed`);
}
volume-mount-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create File to be mounted
run: echo "some text" > someFile
- name: Run docker action with mounted workspace
uses: ./
id: run-docker
with:
image: docker
options: -v ${{ github.workspace }}:/work
run: |
echo "::set-output name=file-contents::`cat /work/someFile`"
- name: Check if file contents match
uses: actions/github-script@v3
with:
script: |
const fileContents = '${{ steps.run-docker.outputs.file-contents }}';
if (fileContents !== 'some text') {
core.setFailed(`Unable to mount workspace volume`);
}
container-network-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: test
POSTGRES_USER: test
POSTGRES_DB: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- name: Run docker action and test network connection
uses: ./
with:
image: postgres
run: >
pg_isready -d test -U test -h postgres -p ${{ job.services.postgres.ports[5432] }}
options: >
-e PGPASSWORD=test

View File

@@ -1,4 +1,4 @@
FROM docker:19.03 FROM docker:20.10
RUN apk add bash RUN apk add bash

View File

@@ -1,35 +1,31 @@
# 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)). - run a specific step in docker.
- run an image built by a previous step.
- See https://github.com/addnab/docker-run-action/blob/main/action.yml for all the available inputs.
### Why use docker-run-action? ## Examples
- run on a privately-owned image.
- run on an image built by a previous step.
- run a specific step in docker
### Example Usage #### Typical Use Case
#### single-line command
```yaml ```yaml
- uses: addnab/docker-run-action@v1 - name: Checkout
uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume
- uses: addnab/docker-run-action@v3
with: with:
image: docker:latest username: ${{ secrets.DOCKER_USERNAME }}
run: echo "hello world" password: ${{ secrets.DOCKER_PASSWORD }}
``` registry: gcr.io
image: private-image:latest
#### multi-line commands options: -v ${{ github.workspace }}:/work -e ABC=123
```yaml
- uses: addnab/docker-run-action@v1
with:
image: docker:latest
run: | run: |
echo "first line" echo "Running Script"
echo "second line" /work/run-script
``` ```
#### run on a privately-owned image #### run a privately-owned image
```yaml ```yaml
- uses: addnab/docker-run-action@v1 - uses: addnab/docker-run-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
@@ -38,13 +34,13 @@ Github Workflows already supports running on public docker images out-of-the-box
run: echo "hello world" run: echo "hello world"
``` ```
#### run on an image built by a previous step #### run an image built by a previous step
```yaml ```yaml
- uses: docker/build-push-action@v1 - uses: docker/build-push-action@v2
with: with:
repository: test-image tags: test-image:latest
push: false push: false
- uses: addnab/docker-run-action@v1 - uses: addnab/docker-run-action@v3
with: with:
image: test-image:latest image: test-image:latest
run: echo "hello world" run: echo "hello world"
@@ -54,7 +50,7 @@ Github Workflows already supports running on public docker images out-of-the-box
#### use a specific shell (default: sh). #### use a specific shell (default: sh).
*Note: The shell must be installed in the container* *Note: The shell must be installed in the container*
```yaml ```yaml
- uses: addnab/docker-run-action@v1 - uses: addnab/docker-run-action@v3
with: with:
image: docker:latest image: docker:latest
shell: bash shell: bash

14
RELEASES.md Normal file
View File

@@ -0,0 +1,14 @@
# addnab/docker-run-action Releases
### 3.0.0
- Upgrade to docker 20.10 https://github.com/addnab/docker-run-action/pull/12
### 2.0.0
- Added support for networking with other containers [#3](https://github.com/addnab/docker-run-action/pull/3) [#7](https://github.com/addnab/docker-run-action/pull/7)
- Added tests [#7](https://github.com/addnab/docker-run-action/pull/7)
### 1.0.0
- Initial release

View File

@@ -2,6 +2,9 @@
name: 'Docker Run Action' name: 'Docker Run Action'
description: 'Run a command in a new container' description: 'Run a command in a new container'
inputs: inputs:
tarball:
description: 'Image tarball'
required: false
image: image:
description: 'Image' description: 'Image'
required: true required: true
@@ -24,6 +27,10 @@ inputs:
password: password:
description: 'Password' description: 'Password'
required: false required: false
docker_network:
description: 'Docker Network ID'
default: ${{ job.container.network }}
required: false
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' image: 'Dockerfile'

View File

@@ -4,6 +4,13 @@ if [ ! -z $INPUT_USERNAME ];
then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin
fi fi
echo "$INPUT_RUN" | sed -e 's/\\n/;/g' > semicolon_delimited_script if [ ! -z $INPUT_DOCKER_NETWORK ];
then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK"
fi
exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "`cat semicolon_delimited_script`" if [ ! -z $INPUT_TARBALL ];
then echo "loading image from $INPUT_TARBALL"
docker load --input $INPUT_TARBALL
fi
exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}"