Skip to content
Open

Pillu #274

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 94 additions & 104 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,108 +1,98 @@
# CI for Product Catalog Service

name: product-catalog-ci

on:
pull_request:
branches:
- main
on:
push:
branches:
- main
paths:
- "**/*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v4

- name: Setup Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Build
run: |
cd src/product-catalog
go mod download
go build -o product-catalog-service main.go

- name: unit tests
run: |
cd src/product-catalog
go test ./...

code-quality:
runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v4

- name: Setup Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
run: golangci-lint run
working-directory: src/product-catalog

docker:
runs-on: ubuntu-latest

needs: build

steps:
- name: checkout code
uses: actions/checkout@v4

- name: Install Docker
uses: docker/setup-buildx-action@v1

- name: Login to Docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Docker Push
uses: docker/build-push-action@v6
with:
context: src/product-catalog
file: src/product-catalog/Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/product-catalog:${{github.run_id}}


updatek8s:
runs-on: ubuntu-latest

needs: docker

steps:
- name: checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Update tag in kubernetes deployment manifest
run: |
sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/product-catalog:${{github.run_id}}|" kubernetes/productcatalog/deploy.yaml

- name: Commit and push changes
run: |
git config --global user.email "abhishek@gmail.com"
git config --global user.name "Abhishek Veeramalla"
git add kubernetes/productcatalog/deploy.yaml
git commit -m "[CI]: Update product catalog image tag"
git push origin HEAD:main -f








build:
runs-on: ubuntu-latest
steps:
- name: checkout-code
uses: actions/checkout@v4

- name: setup Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: build
run: |
cd src/product-catalog
go mod download
go build -o product-catalog-service main.go

- name: unit tests
run: |
cd src/product-catalog
go test ./...

code-quality:
runs-on: ubuntu-latest
steps:
- name: checkout-code
uses: actions/checkout@v4

- name: Run golangci-lint
run: |
go install github.com/golangci-lint/golangci-lint@v1.56.2
$HOME/go/bin/golangci-lint run src/product-catalog/...

docker:
runs-on: ubuntu-latest
needs: build
steps:
- name: checkout-code
uses: actions/checkout@v4

- name: Install Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWARD }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: src/product-catalog
file: src/product-catalog/Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/product-catalog-service:${{ github.run_id }}

updatek8s:
runs-on: ubuntu-latest
needs: docker
steps:
- name: checkout-code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: update tag in kubernetes deployment file
run: |
sed -i "s|image: .*|image: ${{
secrets.DOCKER_USERNAME
}}/product-catalog-service:${{
github.run_id
}}|" kubernetes/product-catalog-deployment.yaml

- name: commit and push changes
run: |
git config --global user.email "yezindagi1234@gmail.com"
git config --global user.name "etoska-12"
git add kubernetes/product-catalog-deployment.yaml
git commit -m "[ci]: update product-catalog image tag"
git push






29 changes: 29 additions & 0 deletions src/product-catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,32 @@ func createClient(ctx context.Context, svcAddr string) (*grpc.ClientConn, error)