name: Build and Push Golang Image

on:
  push:
    paths:
      - 'golang/**'
      - '.gitea/workflows/golang.yml'

jobs:
  build-and-push:
    runs-on: frontstaging
    steps:
      - name: Checkout code
        uses: https://gitea.pena/PenaDevops/actions.git/checkout@v1

      - name: Login to Container Registry
        run: |
          podman login -u "${{ secrets.REGISTRY_USERNAME }}" -p "${{ secrets.REGISTRY_PASSWORD }}" gitea.pena

      - name: Build and Push Image
        run: |
          cd golang
          BRANCH_NAME=${GITEA_REF#refs/heads/}
          podman build -t gitea.pena/penadevops/container-images/golang:${BRANCH_NAME} .
          podman push gitea.pena/penadevops/container-images/golang:${BRANCH_NAME} 