From 2eda0faeeac92447011d8406addb8efe5e697244 Mon Sep 17 00:00:00 2001 From: Akash Date: Sun, 2 Feb 2025 21:31:25 +0530 Subject: [PATCH] fix: enhance token retrieval process in installation workflow for improved accuracy Signed-off-by: Akash --- .github/workflows/installation-chart.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/installation-chart.yaml b/.github/workflows/installation-chart.yaml index 3881476a9de7..e31aa2aa1331 100644 --- a/.github/workflows/installation-chart.yaml +++ b/.github/workflows/installation-chart.yaml @@ -120,7 +120,21 @@ jobs: ls -la $HOME/.kube/karmada.config cat $HOME/.kube/karmada.config - - name: Register cluster + - name: Get token info + id: token run: | export KUBECONFIG=$HOME/.kube/karmada.config - $(karmadactl token create --print-register-command --kubeconfig $HOME/.kube/karmada.config) + CMD=$(karmadactl token create --print-register-command) + TOKEN=$(echo "$CMD" | grep -o '\--token [^ ]*' | cut -d' ' -f2) + HASH=$(echo "$CMD" | grep -o '\--discovery-token-ca-cert-hash [^ ]*' | cut -d' ' -f2) + ENDPOINT=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}') + echo "token=$TOKEN" >> $GITHUB_OUTPUT + echo "hash=$HASH" >> $GITHUB_OUTPUT + echo "endpoint=$ENDPOINT" >> $GITHUB_OUTPUT + + - name: Register cluster + run: | + karmadactl register ${{ steps.token.outputs.endpoint }} \ + --token ${{ steps.token.outputs.token }} \ + --discovery-token-ca-cert-hash ${{ steps.token.outputs.hash }} \ + --kubeconfig $HOME/.kube/karmada.config \ No newline at end of file