## Google Kubernetes Engine - GitHub Actions

Repository：https://github.com/pingcap-inc/gcp-cicd-sample

File: https://pingcap.feishu.cn/wiki/wikcn1tYssGewcp6xfMUxTXMJVr

An example workflow that uses GitHub Actions to deploy a static website to an existing Google Kubernetes Engine cluster.
This code is intended to be an example. You will likely need to change or update values to match your setup.

### Workflow description

For pushes to the main branch, this workflow will:

1. Download and configure the Google Cloud SDK with the provided credentials.
2. Build, tag, and push a container image to Google Artifact Registry.
3. Use a Kubernetes Deployment to push the image to the cluster.

- Note that a GKE deployment requires a unique Tag to update the pods. Using a constant tag latest or a branch name main
  may result in successful workflows that don't update the cluster.

### Setup

1. Create a repository (or select an existing repository).
2. Move into the repository directory:
```bash
    $ cd <repo>
```
3. Copy the example into the repository:

```bash
   $ cp -r <path_to>/gcp-cicd-sample/ .
```

4. Update `.github/workflows/google.yml` to match the values corresponding to your VM.
- NAMESPACE - the namespace of your cluster, and make sure to be unique
- DEPLOYMENT_NAME - the name of your deployment
- IMAGE - your preferred Docker image name

5. Update `deployment.yml` 、 `service.yml` 、 `secret.yml` 、`configmap.yml` 、`apisix-route.yml` to match the values corresponding to your ENV.

6. Update `Dockerfile` to match the values corresponding to your VM.


### Run the workflow

1. Add and commit your changes:

```bash
   $ git add .
   $ git commit -m "Set up GitHub workflow"
```

2. Push to the main branch:
```bash
   $ git push -u origin main
```   
3. View the GitHub Actions Workflow by selecting the Actions tab at the top of your repository on GitHub. Then click on
   the Build and Deploy to GKE element to see the details.