commit #289
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22 | |
- name: Build | |
run: | | |
cd src/product-catalog | |
go mod download | |
go build -v -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: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.2 | |
golangci-lint run ./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 DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Dokcer Push | |
uses: docker/build-push-action@v6 | |
with: | |
context: src/product-catalog | |
file: 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.PERSONAL_GITHUB_TOKEN }} | |
- name: update tag in Kubernetes deployment manifest | |
run: | | |
sed -i 's/tag: .*/image: mishrp/product-catalog${{github.run_id}}/' kubernetes/productcatalog/deploy.yaml | |
- name: Commit and Push changes | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Prbal Mishra" | |
git add kubernetes/productcatalog/deploy.yaml | |
git commit -m "Update Product-catalog" | |
git push | |