name: Deploy Website

on:
  push:
    branches:
      - main
      - master

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3

      - name: Build Docker image
        run: |
          docker build --pull -t akkolli-website:latest .

      - name: Stop existing container
        run: |
          docker stop website-container || true
          docker rm website-container || true

      - name: Run new container
        run: |
          docker run -d \
            --name website-container \
            --restart unless-stopped \
            -p 8080:80 \
            akkolli-website:latest
