-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathaction.yml
More file actions
49 lines (46 loc) · 1.55 KB
/
action.yml
File metadata and controls
49 lines (46 loc) · 1.55 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
name: 'Update Academy'
description: 'Triggers update of academy content for a given orgId and version using an API'
author: 'Layer5'
inputs:
orgId:
description: 'Organization ID to update academy content for'
required: true
token:
description: 'Bearer token for authorization'
required: true
academy-name:
description: 'The name of the Academy being updated (e.g., Layer5 Academy)'
required: false
default: 'Academy'
type: string
version:
description: 'Version of the module to update. Defaults to "latest"'
required: false
default: 'latest'
outputs:
response:
value: ${{ steps.update.outputs.RESOURCE_URL }}
description: 'Response from the API call'
runs:
using: 'composite'
steps:
- name: Call academy update API
shell: bash
id: update
run: |
set -e
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://cloud.layer5.io/api/academy/${{ inputs.orgId }}/update/${{ inputs.version }}" \
-H "Authorization: Bearer ${{ inputs.token }}" \
-H "Content-Type: application/json")
BODY=$(echo "$RESPONSE" | head -n -1)
STATUS=$(echo "$RESPONSE" | tail -n1)
echo "API response status: $STATUS"
echo "API response body: $BODY"
if [[ "$STATUS" -ge 200 && "$STATUS" -lt 300 ]]; then
echo "response<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "::error::Failed to update academy (HTTP $STATUS): $BODY"
exit 1
fi