-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
134 lines (134 loc) · 5.05 KB
/
action.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "Setup CD workspace all in one"
description: "Setup tools and components for Cloud provider(Azure, AliCloud, etc.)"
branding:
icon: cloud
color: white
inputs:
cloud-provider:
description: 'cloud provider: Azure, AliCloud, TBD.'
required: true
azure-client-id:
description: "OIDC client id to login Azure"
required: false
azure-tenant-id:
description: "OIDC tenant id to login Azure"
required: false
azure-subscription-id:
description: "OIDC subscription id to login Azure"
required: false
acr-login-registry:
description: "Azure/AliCloud ACR registry to login"
required: true
acr-username:
description: "Azure/AliCloud ACR username to login"
required: true
acr-password:
description: "Azure/AliCloud ACR password to login"
required: true
azure-aks-resource-group:
description: "Azure AKS cluster resource group"
required: false
azure-aks-cluster-name:
description: "Azure AKS cluster name to use"
required: false
alicloud-ack-cluster-id:
description: "AliCloud ACK cluster id to login"
required: false
alicloud-ack-access-key-id:
description: "AliCloud access key id to login ACK"
required: false
alicloud-ack-access-key-secret:
description: "AliCloud access key secret to login ACK"
required: false
need-cd-tools:
description: "Whether to install CD tools: kubectl, skaffold, kustomize, helm, etc."
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Check cloud-provider-1
if: ${{ inputs.cloud-provider == '' }}
shell: bash
run: |
echo "cloud-provider is required."
exit 1
- name: Check cloud-provider-2
if: ${{ inputs.cloud-provider != 'AliCloud' && inputs.cloud-provider != 'Azure' }}
shell: bash
run: |
echo "current cloud-provider is not supported."
exit 1
- name: Check AliCloud ACR parameters
if: ${{ inputs.cloud-provider == 'AliCloud' && (inputs.acr-login-registry == '' || inputs.acr-username == '' || inputs.acr-password == '') }}
shell: bash
run: |
echo "acr-login-registry, acr-username and acr-password are required."
exit 1
- name: Login to ACR Registry
if: ${{ inputs.cloud-provider == 'AliCloud' }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.acr-login-registry }}
username: ${{ inputs.acr-username }}
password: ${{ inputs.acr-password }}
- name: Check AliCloud ACK parameters
if: ${{ inputs.cloud-provider == 'AliCloud' && (inputs.alicloud-ack-access-key-id == '' || inputs.alicloud-ack-access-key-secret == '' || inputs.alicloud-ack-cluster-id == '') }}
shell: bash
run: |
echo "alicloud-ack-cluster-id, alicloud-ack-access-key-id and alicloud-ack-access-key-secret are required."
exit 1
- name: Set up kubeconfig for ACK cluster
if: ${{ inputs.cloud-provider == 'AliCloud' }}
uses: aliyun/ack-set-context@v1
with:
access-key-id: ${{ inputs.alicloud-ack-access-key-id }}
access-key-secret: ${{ inputs.alicloud-ack-access-key-secret }}
cluster-id: ${{ inputs.alicloud-ack-cluster-id }}
- name: Check Azure Login parameters
if: ${{ inputs.cloud-provider == 'Azure' && (inputs.azure-client-id == '' || inputs.azure-tenant-id == '' || inputs.azure-subscription-id == '') }}
shell: bash
run: |
echo "Azure client-id, tenant-id, subscription-id are required."
exit 1
- uses: azure/login@v1
if: ${{ inputs.cloud-provider == 'Azure' }}
with:
client-id: ${{ inputs.azure-client-id }}
tenant-id: ${{ inputs.azure-tenant-id }}
subscription-id: ${{ inputs.azure-subscription-id }}
- name: Check Azure ACR parameters
if: ${{ inputs.cloud-provider == 'Azure' && (inputs.acr-login-registry == '' || inputs.acr-username == '' || inputs.acr-password == '') }}
shell: bash
run: |
echo "Azure ACR registry, username, password are required."
exit 1
- name: Login to ACR Registry
if: ${{ inputs.cloud-provider == 'Azure' }}
uses: azure/docker-login@v1
with:
login-server: ${{ inputs.acr-login-registry }}
username: ${{ inputs.acr-username }}
password: ${{ inputs.acr-password }}
- name: Check Azure AKS parameters
if: ${{ inputs.cloud-provider == 'Azure' && (inputs.azure-aks-resource-group == '' || inputs.azure-aks-cluster-name == '') }}
shell: bash
run: |
echo "Azure AKS resource group, cluster name are required."
exit 1
- uses: azure/aks-set-context@v3
if: ${{ inputs.cloud-provider == 'Azure' }}
with:
resource-group: ${{ inputs.azure-aks-resource-group }}
cluster-name: ${{ inputs.azure-aks-cluster-name }}
admin: true
- uses: coscene-io/[email protected]
if: ${{ inputs.need-cd-tools == 'true' }}
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
with:
kubectl: '1.25.0'
kustomize: '4.5.7'
skaffold: '2.0.3'
jq: '1.6'
helm: '3.10.2'