Githubcicheck #261
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: Setup Go 1.23.x | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version:1.23.x | ||
| - name: Build | ||
| run: | ||
| cd src/product-catalog | ||
| go mod download | ||
| go build -o product-catalog-service src/product-catalog/main.go | ||
| - name: unit tests | ||
| run: | ||
| cd src/product-catalog | ||
| go mod download | ||
| go test src/product-catalog/... | ||
| code-quality: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Run golangcci-lint | ||
| run: | ||
| go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
| 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 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: Dockerfile | ||
| push: true | ||
| tags: ${{secrets.DOCKER_USERNAME}}/product-catalog-service:${{github.run_id}} | ||
| updatek8: | ||
| 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 "[email protected]" | ||
| git config --global user.name "shahipranav" | ||
| git add kubernetes/productcatalog/deploy.yaml | ||
| git commit -m "[CI]: update product catalog image tag" | ||
| git push | ||