-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
115 lines (103 loc) · 3.97 KB
/
action.yaml
File metadata and controls
115 lines (103 loc) · 3.97 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
105
106
107
108
109
110
111
112
113
114
115
name: 'Ethiack Job Manager Action'
description: 'Integrates Ethiack Job Manager with GitHub Actions for managing Artiacker jobs.'
author: 'Ethiack, Lda'
branding:
icon: 'search'
color: 'green'
inputs:
command:
description: 'The command to run. Available options are "launch", "cancel", "info", "list", "status", "success", "await", and "check".'
required: true
uuid:
description: 'The UUID of the job. Required for commands "cancel", "info", "status", "success", and "await".'
required: false
default: ''
url:
description: 'The URL of the target service. Required for commands "launch", and "check".'
required: false
default: ''
beacon_id:
description: 'The beacon ID of the service. Optional for commands "launch" and "check".'
required: false
default: ''
event_slug:
description: 'The event slug of the service. Optional for commands "launch" and "check".'
required: false
default: ''
args:
description: 'The arguments to pass to the job.'
required: false
default: ''
outputs:
response:
description: 'The response from the Ethiack Job Manager package.'
value: ${{ steps.ethiack-run-command.outputs.response }}
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup environment
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --user --upgrade pipx
echo "PATH=$PATH:/root/.local/bin" >> $GITHUB_ENV
pipx install ethiack-job-manager
shell: bash
- name: Execute Ethiack Job Manager Command
id: ethiack-run-command
run: |
# Run ethiack-job-manager
set +e # Disable exit on error
# Prepare command
COMMAND="ethiack-job-manager ${{ inputs.command }}"
## Add args
if [ -n "${{ inputs.args }}" ]; then
COMMAND="$COMMAND ${{ inputs.args }}"
fi
## Add url input if needed
if [ "${{ inputs.command }}" = "launch" ] || [ "${{ inputs.command }}" = "check" ]; then
if [ -n "${{ inputs.url }}" ]; then
COMMAND="$COMMAND ${{ inputs.url }}"
else
echo "Error: URL is required for the ${{ inputs.command }} command."
exit 1
fi
fi
## Add beacon_id input if provided for launch or check
if [ "${{ inputs.command }}" = "launch" ] || [ "${{ inputs.command }}" = "check" ]; then
if [ -n "${{ inputs.beacon_id }}" ]; then
COMMAND="$COMMAND --beacon-id ${{ inputs.beacon_id }}"
fi
fi
## Add event_slug input if provided for launch or check
if [ "${{ inputs.command }}" = "launch" ] || [ "${{ inputs.command }}" = "check" ]; then
if [ -n "${{ inputs.event_slug }}" ]; then
COMMAND="$COMMAND --event-slug ${{ inputs.event_slug }}"
fi
fi
## Add uuid input if needed
if [ "${{ inputs.command }}" = "cancel" ] || [ "${{ inputs.command }}" = "info" ] || [ "${{ inputs.command }}" = "status" ] || [ "${{ inputs.command }}" = "success" ] || [ "${{ inputs.command }}" = "await" ]; then
if [ -n "${{ inputs.uuid }}" ]; then
COMMAND="$COMMAND ${{ inputs.uuid }}"
else
echo "Error: UUID is required for the ${{ inputs.command }} command."
exit 1
fi
fi
# Run
echo "[ETHIACK-JOB-MANAGER] Executing command: $COMMAND"
RESPONSE=$($COMMAND)
EXIT_CODE=$?
echo "[ETHIACK-JOB-MANAGER] Response:"
echo "$RESPONSE"
echo "response<<EOF"$'\n'"$RESPONSE"$'\n'EOF >> $GITHUB_OUTPUT
echo "[ETHIACK-JOB-MANAGER] Finished."
set -e # Re-enable immediate exit on error
if [ $EXIT_CODE -ne 0 ]; then
echo "[ETHIACK-JOB-MANAGER] Command failed with exit code $EXIT_CODE."
exit $EXIT_CODE
fi
shell: bash