name: Build
on: [workflow_dispatch]

jobs:
  Deploy:
    runs-on: docker
    container:
      image: ghcr.io/catthehacker/ubuntu:act-latest

    steps:
      - name: Install LFS
        run: |
          curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
          apt-get update
          apt-get install -y git-lfs
          git lfs install

      - name: Checkout
        uses: actions/checkout@v4
        with:
          lfs: 'true'

      - name: Docker Login
        run: |
          docker login -u riksolo -p ${{secrets.CONTAINER_REGISTRY_TOKEN}} git.riksolo.com

      - name: Build and push
        run: |
          docker build -t git.riksolo.com/riksolo/eleventy-riksolo-com:latest -t git.riksolo.com/riksolo/eleventy-riksolo-com:${{github.sha}} .
          docker push git.riksolo.com/riksolo/eleventy-riksolo-com:latest
          docker push git.riksolo.com/riksolo/eleventy-riksolo-com:${{github.sha}}
          docker build --build-arg SITE=rblicht -t git.riksolo.com/riksolo/eleventy-riksolo-com:latest-rblicht -t git.riksolo.com/riksolo/eleventy-riksolo-com:${{github.sha}}-rblicht .
          docker push git.riksolo.com/riksolo/eleventy-riksolo-com:latest-rblicht
          docker push git.riksolo.com/riksolo/eleventy-riksolo-com:${{github.sha}}-rblicht

      - name: Trigger Compose Deploy
        uses: https://github.com/fjogeleit/http-request-action@v1
        with:
          url: ${{ vars.DOCKER_COMPOSE_DEPLOY_URL }}
          method: 'POST'
          customHeaders: '{"Content-Type": "application/json", "Authorization": "token ${{secrets.FORGEJO_TOKEN}}"}'
          data: '{"ref": "${{forgejo.ref}}"}'