Skip to content

Commit c0d95ed

Browse files
committed
simplify kubeconfig file creation and setup
1 parent 8268c7c commit c0d95ed

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

action.yaml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,16 @@ runs:
8888
- name: Create kubeconfig file
8989
if: ${{ inputs.kubeconfig != '' }}
9090
run: |
91-
echo "Processing kubeconfig input..."
9291
mkdir -p ~/.kube
93-
if [[ "${{ inputs.kubeconfig }}" =~ ^(/|~|\.)/.*(\.yaml|\.yml|\.config)$ ]]; then
94-
echo "Input appears to be a file path: ${{ inputs.kubeconfig }}"
95-
# If input is a file path, copy it only if it's different from target
96-
input_path=$(realpath -m "${{ inputs.kubeconfig }}")
97-
target_path=$(realpath -m ~/.kube/config)
98-
if [[ "$input_path" != "$target_path" ]]; then
99-
echo "Copying kubeconfig from $input_path to $target_path"
100-
cp "${{ inputs.kubeconfig }}" ~/.kube/config
101-
else
102-
echo "Input path matches target path, skipping copy"
103-
fi
92+
# If input looks like a file path and exists, copy it
93+
if [ -f "${{ inputs.kubeconfig }}" ]; then
94+
echo "Copying kubeconfig from ${inputs.kubeconfig} to ~/.kube/config"
95+
cp -n "${{ inputs.kubeconfig }}" ~/.kube/config
10496
else
105-
echo "Input appears to be direct kubeconfig content, writing to ~/.kube/config"
106-
# If input is the actual kubeconfig content, write it
107-
echo -e "${{ inputs.kubeconfig }}" > ~/.kube/config
97+
# Otherwise treat as content
98+
echo "Input appears to be direct kubeconfig content, writing to $HOME/.kube/config"
99+
echo "${{ inputs.kubeconfig }}" > ~/.kube/config
108100
fi
109-
echo "Kubeconfig setup complete"
110101
shell: bash
111102

112103
- name: Set namespace

0 commit comments

Comments
 (0)