-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathaction.yaml
More file actions
61 lines (58 loc) · 1.93 KB
/
action.yaml
File metadata and controls
61 lines (58 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Docker run action
description: Composite action for running commands in Docker containers
author: "Devito"
inputs:
# The only supported GHA input type is string
uid:
description: "Unique identifier output from docker-build action"
required: true
tag:
description: "Tag of the built image to use"
required: true
name:
description: "Name substring for docker to use when running the command"
default: ""
args:
description: "Arguments to pass to `docker run`, `--init -t --rm` are always added"
required: true
default: ""
env:
description: "Environment variables to set inside the docker container, one environment variable per line"
required: true
default: ""
command:
description: "Command to execute inside of the docker container"
required: true
runs:
using: "composite"
steps:
- id: processenv
name: Process environment variable list
shell: bash
env:
ENV_INPUT: ${{ inputs.env }}
run: |
ENV_STRING=""
# Read line by line with here string, safely handling spaces within the values
while IFS= read -r LINE; do
if [[ -n "$LINE" ]]; then
ENV_STRING="$ENV_STRING --env $LINE"
fi
done <<< "$ENV_INPUT"
# Remove the leading space from the first concatenation
ENV_STRING="${ENV_STRING# }"
echo "docker_environment_args=$ENV_STRING" >> "$GITHUB_OUTPUT"
- id: dockerrun
name: "Run command ${{ inputs.command }} in ${{ inputs.tag }} docker container"
shell: bash
env:
NAME: ${{ input.name }}
run: |
docker run \
--init -t --rm \
${{ inputs.args }} \
--name "ci-${NAME:-${{ inputs.tag }}}-${{ inputs.uid }}" \
--env-file=docker/coverage.env \
${{ steps.processenv.outputs.docker_environment_args }} \
"${{ inputs.tag }}_${{ inputs.uid }}" \
${{ inputs.command }}