File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,20 @@ To use kubectl put this step into your workflow:
21
21
- uses : actions-hub/kubectl@master
22
22
env :
23
23
KUBE_HOST : ${{ secrets.KUBE_HOST }}
24
+ KUBE_CERTIFICATE : ${{ secrets.KUBE_CERTIFICATE }}
24
25
KUBE_USERNAME : ${{ secrets.KUBE_USERNAME }}
25
26
KUBE_PASSWORD : ${{ secrets.KUBE_PASSWORD }}
27
+ with :
28
+ args : get pods
29
+ ` ` `
30
+
31
+ ### Authorization with a bearer token
32
+ ` ` ` yaml
33
+ - uses : actions-hub/kubectl@master
34
+ env :
35
+ KUBE_HOST : ${{ secrets.KUBE_HOST }}
26
36
KUBE_CERTIFICATE : ${{ secrets.KUBE_CERTIFICATE }}
37
+ KUBE_TOKEN : ${{ secrets.KUBE_TOKEN }}
27
38
with :
28
39
args : get pods
29
40
` ` `
Original file line number Diff line number Diff line change @@ -19,12 +19,21 @@ if [ ! -f "$HOME/.kube/config" ]; then
19
19
20
20
echo " $KUBE_CERTIFICATE " | base64 -d > $HOME /.kube/certificate
21
21
kubectl config set-cluster default --server=https://$KUBE_HOST --certificate-authority=$HOME /.kube/certificate > /dev/null
22
- kubectl config set-credentials cluster-admin --username=$KUBE_USERNAME --password=$KUBE_PASSWORD > /dev/null
22
+
23
+ if [ ! -z " ${KUBE_PASSWORD} " ]; then
24
+ kubectl config set-credentials cluster-admin --username=$KUBE_USERNAME --password=$KUBE_PASSWORD > /dev/null
25
+ elif [ ! -z " ${KUBE_TOKEN} " ]; then
26
+ kubectl config set-credentials cluster-admin --token=" ${KUBE_TOKEN} " > /dev/null
27
+ else
28
+ echo " No credentials found. Please provide KUBE_TOKEN, or KUBE_USERNAME and KUBE_PASSWORD. Exiting..."
29
+ exit 1
30
+ fi
31
+
23
32
kubectl config set-context default --cluster=default --namespace=default --user=cluster-admin > /dev/null
24
33
kubectl config use-context default > /dev/null
25
34
26
35
else
27
- echo " No authorization data found. Please provide CONFIG or HTTPS variables. Exiting. ..."
36
+ echo " No authorization data found. Please provide KUBE_CONFIG or KUBE_HOST variables. Exiting..."
28
37
exit 1
29
38
fi
30
39
fi
You can’t perform that action at this time.
0 commit comments