-
Notifications
You must be signed in to change notification settings - Fork 1
Create google.yml #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: AU_gdev_19 <[email protected]>
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
Reviewer's GuideIntroduce 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 workflowsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this 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 imagecommand 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 ofPROJECT_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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Motivation
Solution
PR Checklist
Summary by Sourcery
CI: