Skip to content

Merge pull request #17 from prasadhonrao/feature/api-ci-cd-workflow #1

Merge pull request #17 from prasadhonrao/feature/api-ci-cd-workflow

Merge pull request #17 from prasadhonrao/feature/api-ci-cd-workflow #1

Workflow file for this run

name: API - Build
on:
push:
branches:
- main
paths:
- 'api/**'
pull_request:
branches:
- main
paths:
- 'api/**'
workflow_dispatch:
env:
DOCKER_IMAGE: prasadhonrao/devcamper-api
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t ${{ env.DOCKER_IMAGE }}:${{ github.sha }} -f api/Dockerfile api
docker tag ${{ env.DOCKER_IMAGE }}:${{ github.sha }} ${{ env.DOCKER_IMAGE }}:latest
docker push ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
docker push ${{ env.DOCKER_IMAGE }}:latest