From a99f715fd23412ef069b31ebf77150fd7564f7b2 Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 13 Jun 2024 12:10:17 -0500 Subject: [PATCH 1/3] Add PR image logic --- .github/workflows/build-and-push.yaml | 32 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 90a02d9e..0de72549 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -9,15 +9,15 @@ on: - "master" tags: - "v*" - # pull_request: - # types: - # - 'opened' - # - 'synchronize' - # - 'reopened' - # - 'closed' - # branches: - # - 'develop' - # - 'master' + pull_request: + types: + - 'opened' + - 'synchronize' + - 'reopened' + - 'closed' + branches: + - 'develop' + - 'master' jobs: build: @@ -101,6 +101,20 @@ jobs: type=gha build-args: | RUN_BUILD=false + + - + uses: imjasonh/setup-crane@v0.1 + if: ${{ github.event_name == 'pull_request' }} + + - + name: Preview prep + if: ${{ github.event_name == 'pull_request' }} + run: |- + API_IMAGE=$(echo "${{ steps.deploy-tag.outputs.image_name }}" | sed -e 's/-client/-api/g') + if ! crane config ${API_IMAGE}:${{ steps.deploy-tag.outputs.image_tag }}; then + crane tag ${API_IMAGE}:latest ${{ steps.deploy-tag.outputs.image_tag }} + fi + - name: Summary run: | cat <<-EOT >> "$GITHUB_STEP_SUMMARY" From 5219f0ee59e9cb6f2834ab74ea99d90829a39d59 Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 13 Jun 2024 12:15:49 -0500 Subject: [PATCH 2/3] Fix deploy logic --- .github/workflows/build-and-push.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 0de72549..953f73d8 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -128,6 +128,7 @@ jobs: name: Trigger deploy to ${{ needs.build.outputs.environment_name }} needs: build runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} steps: - name: Generate Webhook Payload id: payload From 3cc8acddfd91254ed3f5c0685f88377f585ba7dd Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 13 Jun 2024 12:28:08 -0500 Subject: [PATCH 3/3] Update tagging logic --- .github/workflows/build-and-push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 953f73d8..9ec7e517 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -72,7 +72,7 @@ jobs: id: deploy-tag run: | # Parse container image tag to deploy - full_tag=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -r '.tags[] | limit(1; select(. | test(":sha-|:v.")))') + full_tag=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -r '.tags[0]') echo "Will use tag \"$full_tag\" for deployment." echo image_tag=$(echo "$full_tag" | cut -f2 -d:) >> "$GITHUB_OUTPUT" echo image_name=$(echo "$full_tag" | cut -f1 -d:) >> "$GITHUB_OUTPUT"