<p>I developed the yaml files for kubernetes and skaffold and the dockerfile. My deployment with Skaffold work well in my local machine.</p>
<p>Now I need to implement the same deployment in my k8s cluster in my Google Cloud project, triggered by new tags in a GitHub repository. I found that I have to use Google Cloud Build, but I don't know how to execute Skaffold from the cloudbuild.yaml file.</p>

<p>There is a skaffold image in <a href="https://github.com/GoogleCloudPlatform/cloud-builders-community" rel="noreferrer">https://github.com/GoogleCloudPlatform/cloud-builders-community</a></p>
<p>To use it, follow the following steps:</p>
<ul>
<li>Clone the repository</li>
</ul>
<pre><code>git clone https://github.com/GoogleCloudPlatform/cloud-builders-community
</code></pre>
<ul>
<li>Go to the skaffold directory</li>
</ul>
<pre><code>cd cloud-builders-community/skaffold
</code></pre>
<ul>
<li>Build the image:</li>
</ul>
<pre><code>gcloud builds submit --config cloudbuild.yaml .
</code></pre>
<p>Then, in your <code>cloudbuild.yaml</code>, you can add a step based on this one:</p>
<pre class="lang-yaml prettyprint-override"><code>- id: 'Skaffold run'
  name: 'gcr.io/$PROJECT_ID/skaffold:alpha' # https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/skaffold
  env:
  - 'CLOUDSDK_COMPUTE_ZONE=us-central1-a'
  - 'CLOUDSDK_CONTAINER_CLUSTER=[YOUR_CLUSTER_NAME]'
  entrypoint: 'bash'
  args:
    - '-c'
    - |
      gcloud container clusters get-credentials [YOUR_CLUSTER_NAME] --region us-central1-a --project [YAOUR_PROJECT_NAME]
      if [ &quot;$BRANCH_NAME&quot; == &quot;master&quot; ]
      then
        skaffold run
      fi
</code></pre>
