Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Dargon789
Copy link
Owner

@Dargon789 Dargon789 commented Oct 13, 2025

Motivation

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Summary by Sourcery

CI:

  • Add .github/workflows/google.yml with triggers on main/master/dev to authenticate via Workload Identity Federation, build and push a Docker image, set up Kustomize, and apply Kubernetes deployment via kubectl

Signed-off-by: AU_gdev_19 <[email protected]>
@vercel vercel bot temporarily deployed to Preview – next October 13, 2025 06:07 Inactive
@vercel
Copy link

vercel bot commented Oct 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
next Ready Ready Preview Comment Oct 13, 2025 6:07am
react Ready Ready Preview Comment Oct 13, 2025 6:07am

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 13, 2025

Reviewer's Guide

Introduce a new GitHub Actions workflow that automates building a Docker image, publishing it to Google Artifact Registry, and deploying to a GKE cluster using Workload Identity Federation.

Sequence diagram for the build and deploy process in the new workflow

sequenceDiagram
  participant GitHubActions as "GitHub Actions Workflow"
  participant GoogleCloud as "Google Cloud"
  participant ArtifactRegistry as "Artifact Registry"
  participant GKE as "GKE Cluster"
  participant Docker as "Docker"
  participant Kustomize as "Kustomize"
  participant Kubectl as "kubectl"

  GitHubActions->>GoogleCloud: Authenticate via Workload Identity Federation
  GitHubActions->>Docker: Build Docker image
  Docker->>ArtifactRegistry: Push image
  GitHubActions->>GoogleCloud: Get GKE credentials
  GitHubActions->>Kustomize: Edit image reference in manifests
  Kustomize->>Kubectl: Build manifests and apply to GKE
  Kubectl->>GKE: Deploy new image
  Kubectl->>GKE: Check rollout status
  Kubectl->>GKE: Get service info
Loading

File-Level Changes

Change Details Files
Add CI/CD pipeline for GKE deployment
  • Trigger on pushes to main/master/dev branches
  • Configure environment variables for GCP project, registry, and cluster
  • Authenticate to Google Cloud via Workload Identity Federation
  • Login Docker to Artifact Registry
  • Retrieve GKE credentials
  • Build and push Docker image with GitHub SHA tags
  • Download and configure Kustomize
  • Deploy to GKE using Kustomize and monitor rollout status
.github/workflows/google.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@snyk-io
Copy link

snyk-io bot commented Oct 13, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The branch filter is using literal quotes around names (e.g. '"main"'), so remove the extraneous quotes for correct YAML syntax.
  • After downloading the kustomize tarball, you need to extract it (e.g. tar -xzf ...) before making it executable.
  • The kustomize edit set image command uses literal placeholders; update it to interpolate the actual env vars (e.g. ${GAR_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/${IMAGE}:${GITHUB_SHA}) instead of PROJECT_ID.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The branch filter is using literal quotes around names (e.g. '"main"'), so remove the extraneous quotes for correct YAML syntax.
- After downloading the kustomize tarball, you need to extract it (e.g. tar -xzf ...) before making it executable.
- The `kustomize edit set image` command uses literal placeholders; update it to interpolate the actual env vars (e.g. `${GAR_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/${IMAGE}:${GITHUB_SHA}`) instead of `PROJECT_ID`.

## Individual Comments

### Comment 1
<location> `.github/workflows/google.yml:39-41` </location>
<code_context>
+on:
+  push:
+    branches:
+      - '"main"'
+      - '"master"'
+      - '"dev"'
+env:
+  PROJECT_ID: 'my-project' # TODO: update to your Google Cloud project ID
</code_context>

<issue_to_address>
**issue (bug_risk):** Branch names are quoted unnecessarily, which may cause workflow trigger issues.

Remove the double quotes from branch names to ensure the workflow triggers correctly on 'main', 'master', and 'dev'.
</issue_to_address>

### Comment 2
<location> `.github/workflows/google.yml:107` </location>
<code_context>
+      # Set up kustomize
+      - name: 'Set up Kustomize'
+        run: |-
+          curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.4.3/kustomize_v5.4.3_linux_amd64.tar.gz
+          chmod u+x ./kustomize
+
</code_context>

<issue_to_address>
**issue (bug_risk):** The curl command downloads a tar.gz file but saves it as 'kustomize' without extracting.

Since the file is still a tar.gz archive, 'chmod' will not make it executable and later steps will fail. Please extract the binary from the archive after downloading.
</issue_to_address>

### Comment 3
<location> `.github/workflows/google.yml:114` </location>
<code_context>
+      - name: 'Deploy to GKE'
+        run: |-
+          # replacing the image name in the k8s template
+          ./kustomize edit set image LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAG=$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA
+          ./kustomize build . | kubectl apply -f -
+          kubectl rollout status deployment/$DEPLOYMENT_NAME
</code_context>

<issue_to_address>
**issue:** Hardcoded placeholders in the kustomize image path may not be replaced as intended.

Use shell variable syntax (e.g., $GAR_LOCATION, $PROJECT_ID) for all dynamic values in the image path to ensure proper substitution during execution.
</issue_to_address>

### Comment 4
<location> `.github/workflows/google.yml:53-60` </location>
<code_context>
+  setup-build-publish-deploy:
+    name: 'Setup, Build, Publish, and Deploy'
+    runs-on: 'ubuntu-latest'
+    environment: 'production'
+
+    permissions:
</code_context>

<issue_to_address>
**suggestion (bug_risk):** The environment is set to 'production' for all branches, including 'dev' and 'master'.

This configuration risks deploying non-production branches to the production environment. Use branch-specific environment settings to prevent this.

```suggestion
  setup-build-publish-deploy:
    name: 'Setup, Build, Publish, and Deploy'
    runs-on: 'ubuntu-latest'
    environment: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' && 'production' || 'development' }}

    permissions:
      contents: 'read'
      id-token: 'write'
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Dargon789 Dargon789 merged commit e16487b into master Oct 13, 2025
25 checks passed
@Dargon789 Dargon789 deleted the Dargon789-patch-2 branch October 13, 2025 06:09
@Dargon789 Dargon789 mentioned this pull request Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant