-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
44 lines (42 loc) · 1.45 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
name: 'Deploy'
description: 'Deploy YWC workshop'
inputs:
image:
description: Docker image to deploy
required: true
deploymentName:
description: Deployment name
required: true
default: app
port:
description: Deployment port
required: true
type: number
runs:
using: "composite"
steps:
- run: |
if [ -z ${ACTIONS_ID_TOKEN_REQUEST_URL+x} ];
then
echo "Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable. Please set id-token permission to 'write'."
exit 1;
fi
BODY=$(jq --null-input \
--argjson image "$IMAGE" \
--arg deploymentName "$DEPLOYMENT_NAME" \
--argjson port "$PORT" \
--argjson env "$ENV" \
'{"image": $image, "deploymentName": $deploymentName, "port": $port, "env": $env}')
echo "Deploying with $BODY"
OIDC_TOKEN=$(curl -sLS "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=deploy.ywc.in.th" -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN")
JWT=$(echo $OIDC_TOKEN | jq -j '.value')
curl -sLS --fail-with-body -X POST https://deploy.ywc.in.th \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d "$BODY"
env:
IMAGE: ${{ toJson(inputs.image) }}
DEPLOYMENT_NAME: ${{ inputs.deploymentName }}
PORT: ${{ inputs.port }}
ENV: ${{ toJson(env) }}
shell: bash