name: Build release image

on:
  push:
    tags:
      - "*.*.*"

jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout source code
        uses: actions/checkout@v4
      - name: Set up NodeJS
        uses: actions/setup-node@v4
        with:
          node-version: 18
      - name: Get dependencies
        working-directory: ${{ gitea.workspace }}
        run: |
          npm install --global yarn
          yarn
      - name: Build website
        working-directory: ${{ gitea.workspace }}
        run: |
          yarn build
      - name: Login to Registry
        uses: docker/login-action@v3
        with:
          registry: git.nicelycomposed.codes
          username: ${{ secrets.IMAGE_REGISTRY_USER }}
          password: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Build Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: |
            git.nicelycomposed.codes/yevi.org/www-yevi-org:${{ gitea.ref_name }}
            git.nicelycomposed.codes/yevi.org/www-yevi-org:latest
