From 8bdcaaef09f192e54500a172ed4b76724eba0d33 Mon Sep 17 00:00:00 2001 From: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:45:03 +0100 Subject: [PATCH] add infra image build to default publish workflow --- .github/workflows/publish-infra.yml | 35 +++++++++++++++++++++++------ .github/workflows/publish.yml | 5 +++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-infra.yml b/.github/workflows/publish-infra.yml index ec67436a6..00fc62e8b 100644 --- a/.github/workflows/publish-infra.yml +++ b/.github/workflows/publish-infra.yml @@ -1,6 +1,7 @@ name: "🚢 Publish Infra Images" on: + workflow_call: push: tags: - "infra-dev-*" @@ -48,20 +49,40 @@ jobs: - name: Generate image reference id: prep - # WARNING: This step expects the workflow to have been triggered by a specific tag format of: infra-${env}-* run: | - env=$(echo ${{ github.ref_name }} | cut -d- -f2) - sha=${GITHUB_SHA::7} - ts=$(date +%s) + # set image repo if [[ "${{ matrix.package }}" == *-provider ]]; then - provider_type=$(echo ${{ matrix.package }} | cut -d- -f1) + provider_type=$(echo "${{ matrix.package }}" | cut -d- -f1) repository=provider/${provider_type} else - repository=${{ matrix.package }} + repository="${{ matrix.package }}" fi - echo "IMAGE_TAG=${env}-${sha}-${ts}" >> "$GITHUB_OUTPUT" echo "REPOSITORY=${repository}" >> "$GITHUB_OUTPUT" + # set image tag + if [[ "${{ github.ref_type }}" == "tag" ]]; then + if [[ "${{ github.ref_name }}" == infra-*-* ]]; then + env=$(echo ${{ github.ref_name }} | cut -d- -f2) + sha=${${{ github.sha }}::7} + ts=$(date +%s) + image_tag=${env}-${sha}-${ts} + elif [[ "${{ github.ref_name }}" == v.docker.* ]]; then + version="${${{ github.ref_name }}#v.docker.}" + image_tag="v${version}" + elif [[ "${{ github.ref_name }}" == build-* ]]; then + image_tag="${${{ github.ref_name }}#build-}" + else + echo "Invalid tag: ${{ github.ref_name }}" + exit 1 + fi + elif [[ "${{ github.ref_name }}" == "main" ]]; then + image_tag="main" + else + echo "Invalid reference: ${{ github.ref }}" + exit 1 + fi + echo "IMAGE_TAG=${image_tag}" >> "$GITHUB_OUTPUT" + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 73d15343b..fdef9ab4a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -57,3 +57,8 @@ jobs: needs: [typecheck, units] uses: ./.github/workflows/publish-docker.yml secrets: inherit + + publish-infra: + needs: [typecheck, units] + uses: ./.github/workflows/publish-infra.yml + secrets: inherit