name: Main CI/CD

on:
  push:
    branches:
      - main

jobs:
  build-and-push:
    name: Build and push
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - uses: docker/login-action@v1
        with:
          registry: registry.btwazure.com
          username: ${{ secrets.HARBOR_USERNAME  }}
          password: ${{ secrets.HARBOR_PASSWORD }}
      - name: Build & Push
        env:
          REGISTRY: ${{ secrets.REGISTRY }}
          IMAGE_TAG: ${{gitea.sha}}
        run: |
          docker build --pull --no-cache=true --tag $REGISTRY --tag $REGISTRY:$IMAGE_TAG  .
          docker push $REGISTRY
          docker push $REGISTRY:$IMAGE_TAG
          docker rmi $(docker images -q $REGISTRY:$IMAGE_TAG) -f