name: Docker Release on: push: tags: - 'api/v*' - 'web/v*' env: # Placeholder for Docker Hub username/organization or GHCR owner DOCKER_REGISTRY_OWNER: ghcr.io/${{ github.repository_owner }} API_IMAGE_NAME: api-service WEB_IMAGE_NAME: web-service jobs: build_and_push_api: name: Build and Push API Image if: startsWith(github.ref, 'refs/tags/api/v') # Trigger only for API tags runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner steps: - name: Checkout code at the specific tag uses: actions/checkout@v4 with: ref: ${{ github.ref }} # Checks out the specific API tag - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract API version from Git tag id: api_version_extractor # Renamed for clarity run: | # github.ref_name will be like "api/v1.2.3" VERSION=$(echo "${{ github.ref_name }}" | sed 's#^api/v##') if [ -z "$VERSION" ]; then # Should not happen due to startsWith condition echo "Could not extract version from tag: ${{ github.ref_name }}" VERSION="unknown" fi echo "API_VERSION_ENV=$VERSION" >> $GITHUB_ENV # Set for current job echo "api_version_output=$VERSION" >> $GITHUB_OUTPUT # Output for other steps if needed echo "Extracted API version: $VERSION" shell: bash - name: Log in to Docker Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push API image uses: useblacksmith/build-push-action@v1 with: context: ./api file: ./api/Dockerfile # Assuming this Dockerfile is for api/server push: true tags: | ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ env.API_VERSION_ENV }} ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ github.sha }} # SHA of the tag commit ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:latest cache-from: type=gha cache-to: type=gha,mode=max build_and_push_web: name: Build and Push Web Image if: startsWith(github.ref, 'refs/tags/web/v') # Trigger only for Web tags runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner steps: - name: Checkout code at the specific tag uses: actions/checkout@v4 with: ref: ${{ github.ref }} # Checks out the specific Web tag - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract Web version from Git tag id: web_version_extractor # Renamed for clarity run: | # github.ref_name will be like "web/v1.2.3" VERSION=$(echo "${{ github.ref_name }}" | sed 's#^web/v##') if [ -z "$VERSION" ]; then # Should not happen due to startsWith condition echo "Could not extract version from tag: ${{ github.ref_name }}" VERSION="unknown" fi echo "WEB_VERSION_ENV=$VERSION" >> $GITHUB_ENV # Set for current job echo "web_version_output=$VERSION" >> $GITHUB_OUTPUT # Output for other steps if needed echo "Extracted Web version: $VERSION" shell: bash - name: Log in to Docker Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Web image uses: useblacksmith/build-push-action@v1 with: context: ./web file: ./web/Dockerfile push: true tags: | ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ env.WEB_VERSION_ENV }} ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ github.sha }} # SHA of the tag commit ${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:latest build-args: | NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} NEXT_PUBLIC_URL=${{ secrets.NEXT_PUBLIC_URL }} NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} NEXT_PUBLIC_SUPABASE_ANON_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} cache-from: type=gha cache-to: type=gha,mode=max