on:
  workflow_call:
    secrets:
      DOCKER_USERNAME:
        required: true
      DOCKER_PASSWORD:
        required: true

jobs:
  build-docker-container:
    runs-on: ubuntu-latest
    container: docker.io/palkerecs/kaniko:alpine
    steps:
      - uses: actions/checkout@v3
      - run: apk add skopeo
        name: Instal authentication helper
      - run: skopeo login --compat-auth-file /kaniko/.docker/config.json -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} --tls-verify=false gitea-http.gitea.svc.cluster.local:3000
        name: Login to container registry
      - run: /kaniko/executor --context "${{ github.workspace }}" --dockerfile "${{ github.workspace }}/Dockerfile" --insecure --destination "gitea-http.gitea.svc.cluster.local:3000/${{ github.repository }}:${{ github.sha }}" --cache=true
        name: Build and publish container