name: Build and Deploy on: push: branches: - main - testing tags: - 'v*' workflow_dispatch: jobs: prepare: name: 🔍 Prepare runs-on: docker container: image: catthehacker/ubuntu:act-latest outputs: target: ${{ steps.determine.outputs.target }} image_tag: ${{ steps.determine.outputs.image_tag }} env_file: ${{ steps.determine.outputs.env_file }} project_name: ${{ steps.determine.outputs.project_name }} next_public_url: ${{ steps.determine.outputs.next_public_url }} steps: - name: Checkout repository uses: actions/checkout@v4 - name: Determine Environment id: determine run: | TARGET="skip" if [[ "${{ github.ref_name }}" == "main" ]]; then TARGET="staging" IMAGE_TAG="main-${{ github.sha }}" ENV_FILE=".env.staging" TRAEFIK_HOST="staging.e-tib.com" fi echo "target=$TARGET" >> $GITHUB_OUTPUT echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT echo "env_file=$ENV_FILE" >> $GITHUB_OUTPUT echo "project_name=etib-$TARGET" >> $GITHUB_OUTPUT echo "next_public_url=https://$TRAEFIK_HOST" >> $GITHUB_OUTPUT build: name: 🏗️ Build needs: prepare if: needs.prepare.outputs.target != 'skip' runs-on: docker container: image: catthehacker/ubuntu:act-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: 🐳 Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver: docker - name: 🔐 Registry Login run: echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin - name: 🏗️ Build and Push uses: docker/build-push-action@v5 with: context: . push: true tags: registry.infra.mintel.me/mintel/e-tib.com:${{ needs.prepare.outputs.image_tag }}