-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
104 lines (92 loc) · 3.2 KB
/
Copy pathaction.yml
File metadata and controls
104 lines (92 loc) · 3.2 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: "Send CDEvents"
description: "Send CDEvents using cdviz-collector send subcommand"
author: "cdviz-dev"
branding:
icon: "send"
color: "blue"
inputs:
data:
description: "JSON data to send to the sink. Can be direct JSON string, file path (@file.json), or stdin (@-)"
required: true
url:
description: "HTTP URL to send the data to. When specified, automatically enables the HTTP sink"
required: false
config:
description: "TOML configuration content for advanced sink settings"
required: false
directory:
description: "Working directory for relative paths"
required: false
headers:
description: 'Additional HTTP headers for the request (one per line, format: "Header-Name: value")'
required: false
additional-args:
description: "Additional arguments to pass to the cdviz-collector send command"
required: false
version:
description: "Version/tag of the cdviz-collector container to use"
required: false
default: "latest"
runs:
using: "composite"
steps:
- name: "Create secure config file"
shell: bash
if: ${{ inputs.config != '' }}
run: |
# Create config file with readable permissions for container
cat > .cdviz-config-${{ github.run_id }}.toml << 'EOF'
${{ inputs.config }}
EOF
# Set permissions to be readable by container (644)
chmod 644 .cdviz-config-${{ github.run_id }}.toml
- name: "Build command arguments"
shell: bash
id: args
run: |
ARGS="send --data '${{ inputs.data }}'"
if [ -n "${{ inputs.url }}" ]; then
ARGS="$ARGS --url '${{ inputs.url }}'"
fi
if [ -n "${{ inputs.config }}" ]; then
ARGS="$ARGS --config '.cdviz-config-${{ github.run_id }}.toml'"
fi
if [ -n "${{ inputs.directory }}" ]; then
ARGS="$ARGS --directory '${{ inputs.directory }}'"
fi
if [ -n "${{ inputs.headers }}" ]; then
while IFS= read -r header; do
if [ -n "$header" ]; then
ARGS="$ARGS --header '$header'"
fi
done <<< '${{ inputs.headers }}'
fi
if [ -n "${{ inputs.additional-args }}" ]; then
ARGS="$ARGS ${{ inputs.additional-args }}"
fi
echo "args=$ARGS" >> $GITHUB_OUTPUT
echo "Command to execute: cdviz-collector $ARGS"
- name: "Run cdviz-collector"
shell: bash
run: |
# Build environment variable arguments for CDVIZ_COLLECTOR__ prefixed variables
ENV_ARGS=""
while IFS='=' read -r name value; do
if [[ "$name" == CDVIZ_COLLECTOR__* ]]; then
ENV_ARGS="$ENV_ARGS -e $name=$value"
fi
done < <(env)
docker run --rm \
-v "$PWD:/workspace" \
-w /workspace \
$ENV_ARGS \
ghcr.io/cdviz-dev/cdviz-collector:${{ inputs.version }} \
${{ steps.args.outputs.args }}
- name: "Clean up config file"
shell: bash
if: ${{ always() && inputs.config != '' }}
run: |
if [ -f ".cdviz-config-${{ github.run_id }}.toml" ]; then
rm -f ".cdviz-config-${{ github.run_id }}.toml"
echo "Cleaned up temporary config file"
fi