name: Build and Push Docker Image

on:
  push:
    branches:
      - main

jobs:
  build-and-push:
    runs-on: ubuntu-latest

    steps:
      # Checkout the repository
      - name: Checkout code
        uses: actions/checkout@v3

      # Log in to Docker Hub or GitHub Container Registry
      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      # Build the Docker image
      - name: Build Docker image
        run: |
          docker build -t rideaware-landing-page:latest .

      # Tag the image
      - name: Tag Docker image
        run: |
          docker tag rideaware-landing-page:latest username/rideaware-landing-page:latest

      # Push the Docker image
      - name: Push Docker image
        run: |
          docker push username/rideaware-landing-page:latest
