-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
69 lines (69 loc) · 2.49 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
name: "Molnett - Setup Molnctl"
description: "Downloads and configures molnctl"
branding:
icon: "download-cloud"
color: "orange"
inputs:
version:
description: "The version of molnctl to install, see https://github.com/molnett/molnctl/releases"
required: false
default: "v0.3.3"
api-token-client-id:
description: "Go to https://app.molnett.org/organization/settings/api-tokens to create a token"
required: true
api-token-client-secret:
description: "The corresponding client secret"
required: true
default-org:
description: "Set this org as default after installation"
required: true
cell:
description: "Default cell"
required: false
runs:
using: "composite"
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux Only"
exit 1
- name: Install Molnctl
shell: bash
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
MOLNETT_CLIENT_ID: ${{ inputs.api-token-client-id }}
MOLNETT_CLIENT_SECRET: ${{ inputs.api-token-client-secret }}
CELL: ${{ inputs.cell }}
run: |
gh release download --repo molnett/molnctl -p 'molnctl*' $VERSION
chmod +x molnctl-x86_64-unknown-linux-gnu
sudo mv molnctl-x86_64-unknown-linux-gnu /usr/bin/molnctl
mkdir ~/.config/molnett
if [ -z "$CELL" ]; then
MOLNETT_API_URL=https://api.molnett.org
MOLNETT_TOKEN=$(curl https://auth.molnett.org/oauth2/token -X POST --data "client_id=$MOLNETT_CLIENT_ID&grant_type=client_credentials&client_secret=$MOLNETT_CLIENT_SECRET" | jq -r .access_token)
else
MOLNETT_API_URL=https://api.$CELL.molnett.app
MOLNETT_TOKEN=$(curl https://auth.$CELL.molnett.app/oauth2/token -X POST --data "client_id=$MOLNETT_CLIENT_ID&grant_type=client_credentials&client_secret=$MOLNETT_CLIENT_SECRET" | jq -r .access_token)
fi
EXPIRY=$(date -u -d "+24 hours" +"%Y-%m-%dT%H:%M:%S.%NZ")
cat << EOF > ~/.config/molnett/config.json
{
"token": {
"access_token": "$MOLNETT_TOKEN",
"refresh_token": null,
"expiry": "$EXPIRY"
},
"url": "$MOLNETT_API_URL"
}
EOF
molnctl orgs list
echo "molnctl sucessfully installed!"
- name: Set Default Org
shell: bash
env:
ORG: ${{ inputs.default-org }}
run: molnctl orgs switch $ORG