minor fix #15
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: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
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.ENVIRONMENT }} | |
run: | | |
cd test | |
go test | |
- name: Build and push Docker image | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
DB_URI: ${{ secrets.DB_URI }} | |
run: | | |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin | |
docker build --build-arg JWT_SECRET=${JWT_SECRET} --build-arg DB_URI=${DB_URI} -t piyush7833/chat-api:latest . | |
docker push piyush7833/chat-api:latest |