-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (53 loc) · 1.71 KB
/
jlab-deploy-app.yaml
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
name: JLab Deploy App
on:
workflow_call:
secrets:
DEPLOYER_USERNAME:
required: true
DEPLOYER_PASSWORD:
required: true
inputs:
env:
required: true
type: string
app:
required: true
type: string
ver:
required: true
type: string
workflow_dispatch:
secrets:
DEPLOYER_USERNAME:
required: true
DEPLOYER_PASSWORD:
required: true
inputs:
env:
required: true
description: "env name"
type: string
app:
required: true
description: "app name"
type: string
ver:
required: true
description: "semantic version"
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
-
run: |
TOKEN_URL="https://ace.jlab.org/auth/realms/ace/protocol/openid-connect/token"
DEPLOY_URL="https://ace.jlab.org/adm/deploy"
CLIENT_ID="${{ secrets.DEPLOYER_USERNAME }}"
SECRET="${{ secrets.DEPLOYER_PASSWORD }}"
JSON_RESPONSE=$(curl -s -u $CLIENT_ID:$SECRET -d "grant_type=client_credentials" "$TOKEN_URL")
TOKEN_ERROR=$(echo $JSON_RESPONSE | jq -j '.error')
if [ "${TOKEN_ERROR}" = "null" ]; then echo "no token error"; else echo "token error: ${TOKEN_ERROR}"; exit 1; fi
ACCESS_TOKEN=$(echo $JSON_RESPONSE | jq -j '.access_token')
if [ "${ACCESS_TOKEN}" = "null" ]; then echo "token is null"; exit 1; else echo "token is not null"; fi
curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "Content-Type: application/x-www-form-urlencoded" -d "env=${{ inputs.env }}&app=${{ inputs.app }}&ver=${{ inputs.ver }}" ${DEPLOY_URL}