Skip to content

[CI]: Update checkout deployment image tag #10

[CI]: Update checkout deployment image tag

[CI]: Update checkout deployment image tag #10

Workflow file for this run

name: checkout-service-ci
on:
push:
paths:
- '.github/workflows/checkout.yaml'
- 'src/checkout/**'
pull_request:
branches: [main]
jobs:
unit-testing:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Build
run: |
cd src/checkout
go mod download
go build -o checkout main.go
- name: unit tests
run: |
cd src/checkout/
go test -v ./...
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22
- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.41.1
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Run golangci-lint
working-directory: ./src/checkout
run: |
go mod tidy
golangci-lint run ./... --timeout 5m
build-and-push:
runs-on: ubuntu-latest
needs: [unit-testing, code-quality]
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@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./src/checkout/Dockerfile
push: true
tags: neamulkabiremon/checkout:${{ github.sha }}
update-k8s-deployment:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update Kubernetes Deployment
run: |
sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/checkout:${{ github.sha }}|" kubernetes/checkout/deploy.yaml
cat kubernetes/checkout/deploy.yaml
- name: Commit and push updated Kubernetes manifest
run: |
git config --global user.email "neamulkabiremon@gmail.com"
git config --global user.name "neamulkabiremon"
git add kubernetes/checkout/deploy.yaml
git commit -m "[CI]: Update checkout deployment image tag"
git push