name: Gitea CI/CD

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Login to Docker registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          registry: https://registry.rokoh.com

      - name: Build Docker image
        run: docker build -t registry.rokoh.com/your-image-name:${{ github.sha }} .

      - name: Push Docker image to registry
        run: docker push registry.rokoh.com/your-image-name:${{ github.sha }}

  deploy:
    runs-on: ubuntu-latest

    needs: build

    steps:
      - name: Install Docker
        uses: docker/setup-action@v2

      - name: Pull Docker image from registry
        run: docker pull registry.rokoh.com/your-image-name:${{ github.sha }}

      - name: Run Docker container
        run: docker run -d -p 80:80 registry.rokoh.com/your-image-name:${{ github.sha }}
