-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
83 lines (77 loc) · 2.5 KB
/
action.yml
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
name: 'PipeCD Register Event'
description: 'Register an event to PipeCD'
inputs:
api-address:
description: 'gRPC address to the PipeCD api server'
required: true
default: ''
api-key:
description: 'API key to which the READ_WRITE role is attached'
required: true
default: ''
event-name:
description: 'The name of Event'
required: true
default: ''
data:
description: 'The string value of event data'
required: true
default: ''
labels:
description: 'The comma-separated list of labels for the event. Format: key=value,key2=value2'
required: false
default: ''
contexts:
description: 'Require pipectl >= v0.49.3. The comma-separated list of contexts for the event. Format: key=value,key2=value2'
required: false
default: ''
pipectl-version:
description: 'The version of pipectl command. Release versions: https://github.com/pipe-cd/pipecd/releases'
required: false
default: 'v0.49.3'
runs:
using: 'composite'
steps:
- name: download pipectl
shell: bash -xe {0}
run: |
PLATFORM=""
if [ "$(uname)" == 'Darwin' ]; then
PLATFORM='darwin'
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
PLATFORM='linux'
else
echo "UNSUPPORTED PLATFORM!!: $(uname -a)" 1>&2
exit 1
fi
ARCH=""
if [ "$(uname -m)" == 'arm64' ]; then
ARCH='arm64'
elif [ "$(uname -m)" == 'aarch64' ]; then
ARCH='arm64'
elif [ "$(uname -m)" == 'x86_64' ]; then
ARCH='amd64'
else
echo "UNSUPPORTED ARCHITECTURE!!: $(uname -a)" 1>&2
exit 1
fi
PIPECTL=/tmp/pipecd-event-register/pipectl
curl -L --silent --create-dirs -o ${PIPECTL} https://github.com/pipe-cd/pipecd/releases/download/${{ inputs.pipectl-version }}/pipectl_${{ inputs.pipectl-version }}_${PLATFORM}_${ARCH}
chmod +x ${PIPECTL}
- name: register event
shell: bash -e {0}
run: |
PIPECTL=/tmp/pipecd-event-register/pipectl
OPTIONS=(
--address=${{ inputs.api-address }}
--api-key=${{ inputs.api-key }}
--name=${{ inputs.event-name }}
--data=${{ inputs.data }}
)
if [ -n "${{ inputs.labels }}" ]; then
OPTIONS+=(--labels=${{ inputs.labels }})
fi
if [ -n "${{ inputs.contexts }}" ]; then
OPTIONS+=(--contexts=${{ inputs.contexts }})
fi
${PIPECTL} event register "${OPTIONS[@]}"