<p>I have a workflow on Github action that builds, tests, and pushes a container to GKE.
I followed the steps outlined in <a href="https://docs.github.com/en/actions/guides/deploying-to-google-kubernetes-engine" rel="nofollow noreferrer">https://docs.github.com/en/actions/guides/deploying-to-google-kubernetes-engine</a> but my build keeps on failing.
The failure comes from the Kustomization stage of the build process.</p>
<p>This is what the error looks like:</p>
<pre><code>Run ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
  ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
  ./kustomize build . | kubectl apply -f -
  kubectl rollout status deployment/$DEPLOYMENT_NAME
  kubectl get services -o wide
  shell: /usr/bin/bash -e ***0***
  env:
    PROJECT_ID: ***
    GKE_CLUSTER: codematictest
    GKE_ZONE: us-east1-b
    DEPLOYMENT_NAME: codematictest
    IMAGE: codematictest
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
    KUBECONFIG: /home/runner/work/codematic-test/codematic-test/fb7d2ebb-4c82-4d43-af10-5b0b62bab1fd
Error: Missing kustomization file 'kustomization.yaml'.

Usage:
  kustomize edit set image [flags]

Examples:

The command
  set image postgres=eu.gcr.io/my-project/postgres:latest my-app=my-registry/my-app@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add

images:
- name: postgres
  newName: eu.gcr.io/my-project/postgres
  newTag: latest
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
  name: my-app
  newName: my-registry/my-app

to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.

The command
  set image node:8.15.0 mysql=mariadb alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add

images:
- name: node
  newTag: 8.15.0
- name: mysql
  newName: mariadb
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
  name: alpine

to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.


Flags:
  -h, --help   help for image

Error: Process completed with exit code 1.
</code></pre>
<p>My GitHub workflow file looks like this:</p>
<pre><code>name: gke

on: push

env:
  PROJECT_ID: ${{ secrets.GKE_PROJECT }}
  GKE_CLUSTER: codematictest
  GKE_ZONE: us-east1-b
  DEPLOYMENT_NAME: codematictest
  IMAGE: codematictest

jobs:
  setup-build-publish-deploy:
    name: Setup, Build, Publish, and Deploy
    defaults:
      run:
        working-directory: api
    runs-on: ubuntu-latest
    environment: production

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    # Setup gcloud CLI
    - uses: google-github-actions/setup-gcloud@v0.2.0
      with:
        service_account_key: ${{ secrets.GKE_SA_KEY }}
        project_id: ${{ secrets.GKE_PROJECT }}

    # Configure Docker to use the gcloud command-line tool as a credential
    # helper for authentication
    - run: |-
        gcloud --quiet auth configure-docker

    # Get the GKE credentials so we can deploy to the cluster
    - uses: google-github-actions/get-gke-credentials@v0.2.1
      with:
        cluster_name: ${{ env.GKE_CLUSTER }}
        location: ${{ env.GKE_ZONE }}
        credentials: ${{ secrets.GKE_SA_KEY }}

    # Build the Docker image
    - name: Build
      run: |-
        docker build \
          --tag &quot;gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA&quot; \
          --build-arg GITHUB_SHA=&quot;$GITHUB_SHA&quot; \
          --build-arg GITHUB_REF=&quot;$GITHUB_REF&quot; \
          .

    # Push the Docker image to Google Container Registry
    - name: Publish
      run: |-
        docker push &quot;gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA&quot;

    # Set up kustomize
    - name: Set up Kustomize
      run: |-
        curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
        chmod u+x ./kustomize

    # Deploy the Docker image to the GKE cluster
    - name: Deploy
      run: |-
        ./kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA
        ./kustomize build . | kubectl apply -f -
        kubectl rollout status deployment/$DEPLOYMENT_NAME
        kubectl get services -o wide
</code></pre>

<p>The kustomization file, as explained in it's <a href="https://github.com/kubernetes-sigs/kustomize#usage" rel="nofollow noreferrer">repository</a>, should be in the next file structure:</p>
<pre><code>~/someApp
├── deployment.yaml
├── kustomization.yaml
└── service.yaml
</code></pre>
