Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- 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`"
echo "docker-version=$(echo $DOCKER_VERSION)" >> $GITHUB_OUTPUT
- name: Test the output
uses: actions/github-script@v3
uses: actions/github-script@v6
with:
script: |
const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}';
Expand All @@ -29,7 +29,7 @@ jobs:
volume-mount-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Create File to be mounted
run: echo "some text" > someFile
- name: Run docker action with mounted workspace
Expand All @@ -39,9 +39,9 @@ jobs:
image: docker
options: -v ${{ github.workspace }}:/work
run: |
echo "::set-output name=file-contents::`cat /work/someFile`"
echo "file-contents=$(cat /work/someFile)" >> $GITHUB_OUTPUT
- name: Check if file contents match
uses: actions/github-script@v3
uses: actions/github-script@v6
with:
script: |
const fileContents = '${{ steps.run-docker.outputs.file-contents }}';
Expand All @@ -61,7 +61,7 @@ jobs:
- 5432:5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run docker action and test network connection
uses: ./
with:
Expand Down
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

```yaml
- name: Checkout
uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume
uses: actions/checkout@v4 # Required to mount the Github Workspace to a volume
- uses: addnab/docker-run-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
24 changes: 24 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'
const child_process = require('child_process')
var child = child_process.spawn(__dirname + '/action.sh', [], { stdio: 'inherit' })

// kill child on signals SIGINT and SIGTERM
function handle(signal) {
console.log('Forwarding signal ' + signal + ' to child process')
// Escalate signal INT -> TERM -> KILL
// https://github.com/ringerc/github-actions-signal-handling-demo
if (signal == 'SIGINT') { signal = 'SIGTERM' }
else if (signal == 'SIGTERM') { signal = 'SIGKILL' }
child.kill(signal)
}
process.on('SIGINT', handle)
process.on('SIGTERM', handle)

// exit if child exits
child.on('exit', function (exit_code) {
exit_code = exit_code !== null ? exit_code : 143
process.exit(exit_code)
})

// keep process running
setInterval(function () { }, 10000);
19 changes: 19 additions & 0 deletions action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
if [ -n "$INPUT_USERNAME" ];
then echo "$INPUT_PASSWORD" | docker login "$INPUT_REGISTRY" -u "$INPUT_USERNAME" --password-stdin
fi

if [ -n "$INPUT_DOCKER_NETWORK" ];
then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK"
fi

echo "docker run -v \"/var/run/docker.sock\":\"/var/run/docker.sock\" \
-v /home/runner/work/_temp:/home/runner/work/_temp \
-e GITHUB_ENV -e GITHUB_OUTPUT -e GITHUB_PATH -e GITHUB_STATE -e GITHUB_STEP_SUMMARY \
$INPUT_OPTIONS --entrypoint=\"$INPUT_SHELL\" \"$INPUT_IMAGE\" -c \"${INPUT_RUN//$'\n'/;}\""

exec docker run \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-v /home/runner/work/_temp:/home/runner/work/_temp \
-e GITHUB_ENV -e GITHUB_OUTPUT -e GITHUB_PATH -e GITHUB_STATE -e GITHUB_STEP_SUMMARY \
$INPUT_OPTIONS --entrypoint="$INPUT_SHELL" "$INPUT_IMAGE" -c "${INPUT_RUN//$'\n'/;}"
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ inputs:
default: ${{ job.container.network }}
required: false
runs:
using: 'docker'
image: 'Dockerfile'
using: 'node20'
main: 'action.js'
11 changes: 0 additions & 11 deletions entrypoint.sh

This file was deleted.