name: Build a docker image for node-jellyfin-role-ot
run-name: ${{ gitea.actor }} is building an image
on: 
  push:
    branches:
      - "feat/cicd"
    secrets:
      TOKEN:
        required: true

env:
  REGISTRY: gitea.brudi.xyz
  IMAGE_NAME: ${{ gitea.repository }}
  USER: ${{ gitea.actor }}

jobs:
  build-docker-image:
    runs-on: ubuntu-latest
    container: catthehacker/ubuntu:act-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Check environment
        run: echo "Registry ${{ env.Registry }} Image ${{ env.IMAGE_NAME }} User ${{ env.USER }}"
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Log in to the Container registry
        run: docker login -u ${{ env.USER }} -p ${{ secrets.TOKEN }} ${{ env.REGISTRY }}
      - name: Build Container
        run: docker build -t ${{ env.REGISTRY }}/${{ env.USER }}/${{ IMAGE_NAME }}:latest .
      - name: Push Container
        run: docker push ${{ env.REGISTRY }}/${{ env.USER }}/${{ IMAGE_NAME }}:latest
