fix cicd #6
This file contains 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
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 #checks project source code into the container | |
- uses: actions/setup-go@v4 #sets up go environment | |
with: | |
go-version: 1.22.2 | |
- name: Install dependencies | |
run: | | |
go mod download | |
- name: test code | |
env: | |
DB_URI: ${{ secrets.TEST_DB_URI }} | |
JWT_SECRET: ${{ secrets.TEST_JWT_SECRET }} | |
ENVIRONMENT: ${{ secrets.ENVIRNONMENT }} | |
run: | | |
cd test | |
go test | |
- name: Build and push Docker image | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t piyush7833/chat-api . | |
docker tag chat-api piyush7833/chat-api | |
docker push piyuhs7833/chat-api |