-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathaction.yml
More file actions
59 lines (52 loc) · 2.53 KB
/
action.yml
File metadata and controls
59 lines (52 loc) · 2.53 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
name: "Run CustoPiZer"
description: "Runs the CustoPiZer tool"
branding:
icon: box
color: green
inputs:
workspace:
description: "Path to the workspace"
required: true
scripts:
description: "Path to the scripts to mount"
required: true
config:
description: "Path to an optional config file 'config.local', e.g. to override file system extending/shrinking"
required: false
default: ''
environment:
description: "Additional environment variables to pass to the docker call, as JSON object, e.g. {'OCTOPRINT_VERSION': '1.7.0', 'OTHER_VAR': 'value'}"
required: false
default: '{}'
custopizer:
description: "CustoPiZer version to use, defaults to 'latest'"
required: false
default: 'latest'
runs:
using: "composite"
steps:
- name: "Validate CustoPiZer action inputs"
run: |
[ -d "${{ inputs.workspace }}" ] || (echo "Validation error: inputs.workspace does not exist or is not a directory!" && exit -1)
[ -d "${{ inputs.scripts }}" ] || (echo "Validation error: inputs.scripts does not exist or is not a directory!" && exit -1)
[ -z "${{ inputs.config }}" ] || [ -f "${{ inputs.config }}" ] || (echo "Validation error: inputs.config does not exist or is not a file!" && exit -1)
[ -z "${{ inputs.environment }}" ] || (echo '${{ inputs.environment }}' | jq) || (echo "Validation error: inputs.environment does not contain valid json!" && exit -1)
[ -z "${{ inputs.custopizer }}" ] || [[ "${{ inputs.custopizer }}" =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$ || "${{ inputs.custopizer }}" =~ sha256:[a-f0-9]{64}$ ]] || (echo "Validation error: inputs.custopizer does not contain a valid version!" && exit -1)
shell: bash
- name: "Run CustoPiZer"
run: |
sudo modprobe loop
config_mount=''
if [ -f "${{ inputs.config }}" ]; then
config_mount="-v ${{ inputs.config }}:/CustoPiZer/config.local"
fi
envs=$(echo '${{ inputs.environment }}' | jq -r 'to_entries | map("-e " + .key + "=" + (.value | tostring)) | join(" ")')
if [[ "${{ inputs.custopizer }}" =~ ^sha256:[a-f0-9]{64}$ ]]; then
version="@${{ inputs.custopizer }}"
else
version=":${{ inputs.custopizer }}"
fi
command="--rm --privileged $envs -v ${{ inputs.workspace }}:/CustoPiZer/workspace -v ${{ inputs.scripts }}:/CustoPiZer/workspace/scripts $config_mount ghcr.io/octoprint/custopizer$version"
echo "About to execute 'docker run $command'..."
docker run $command
shell: bash