kubectl-action
kubectl-action copied to clipboard
Unable to process file command 'env' successfully. Error: Invalid format
Hi. What I'm doing wrong here?
My Workflow:
# setup 'env.AWS_*' variables to run Terraform
- name: "Setup: Configure AWS credentials"
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.aws-iam-role }}
role-session-name: github-actions-terraform
role-duration-seconds: 900
aws-region: us-east-1
- name: "Setup: Generate kubeconfig"
run: echo "EKS_CREDS=$(aws eks update-kubeconfig --region ${{ inputs.aws-region }} --name ${{ inputs.aws-eks-cluster }} --dry-run | base64)" >> $GITHUB_ENV
- name: "Test: Check Kubernetes Pods"
uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ env.EKS_CREDS }}
- run: kubectl get pods -n ${{ inputs.helm-namespace }}
(btw, I've added closing " in the echo "EKS_CREDS=$(...)" command)
But it gives an error:
Run echo "EKS_CREDS=$(aws eks update-kubeconfig --region us-east-1 --name atlas-eks-ops-1-28 --dry-run | base64)" >> $GITHUB_ENV
echo "EKS_CREDS=$(aws eks update-kubeconfig --region us-east-1 --name atlas-eks-ops-1-28 --dry-run | base64)" >> $GITHUB_ENV
shell: /usr/bin/bash -e {0}
env:
grafana_client_secret: ***
alertmanager_opsgenie_api_key: ***
vmauth_password: ***
notion_secret: ***
redshift_secret:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
AWS_SESSION_TOKEN: ***
Error: Unable to process file command 'env' successfully.
Error: Invalid format 'cml0eS1kYXRhOiBMUzB0TFMxQ1JVZEpUaUJEUlZKVVNVWkpRMEZVUlMwdExTMHRDazFKU1VSQ1ZF'
I realized that the readme isn't very clear on this, but since the kubeconfig ends up being multiline you'd need to follow this: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings.
I'll update the readme at some point to fix this.
run: |
{
echo 'EKS_CREDS<<EOF'
aws eks update-kubeconfig --region $AWS_REGION --name $AWS_EKS_CLUSTER --dry-run | base64
echo EOF
} >> $GITHUB_ENV
change to like this, it work for me