Skip to content

Gitcicheck

Gitcicheck #268

Workflow file for this run

# CI for Product Catalog Service
name: product-catalog-ci
on:
pull_request:
branches:
- main
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: Run 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
working-directory: src/product-catalog
args: run
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: 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 || 'in30minthing' }}/product-catalog:${{ github.run_id }}
update-k8s:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update image tag in Kubernetes deployment
run: |
sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME || 'in30minthing' }}/product-catalog:${{ github.run_id }}|" kubernetes/productcatalog/deploy.yaml
- name: Apply Kubernetes deployment
run: |
kubectl apply -f kubernetes/productcatalog/deploy.yaml
- name: Commit updated deployment
run: |
git config --global user.email "[email protected]"
git config --global user.name "khushboo kumari"
git add kubernetes/productcatalog/deploy.yaml
git commit -m "[CI]: Update product catalog image tag" || echo "No changes to commit"
git push origin HEAD:main -f