name: Build and Push Docker Image
on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: self-hosted
    container:
      image: alpine:latest
    steps:
      - name: Set up and Install Dependencies
        run: |
          apk update && apk add --no-cache mariadb-connector-c-dev && apk add --no-cache gcc musl-dev nodejs npm git docker libffi-dev
      - name: Check out repository code
        uses: actions/checkout@v4
      - name: Use server_config_default as primary
        run : mv /workspace/CLERC/Reskreen/Reskreen/server_config_default.py  /workspace/CLERC/Reskreen/Reskreen/server_config.py
      - name: check server_config_default as primary
        run : cat /workspace/CLERC/Reskreen/Reskreen/server_config.py
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Log in to Docker Registry
        uses: docker/login-action@v3
        with:
          registry: registry.prod.resk-u.ch
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Build and Push Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: registry.prod.resk-u.ch/reskreen:latest       

