From 92f2a864a52aeea0c8a10026df4e4dc18c200704 Mon Sep 17 00:00:00 2001 From: Mitch Talmadge <8848080+MitchTalmadge@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:53:30 -0700 Subject: [PATCH 1/3] Fix deploy script --- .github/workflows/deploy-prod.yml | 4 +++- .github/workflows/deploy-staging.yml | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 78fa8f3..1b4f076 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -6,6 +6,8 @@ on: - "master" tags: - v* + workflow_dispatch: + jobs: build: @@ -24,7 +26,7 @@ jobs: path: /tmp - name: "Get Tag Name" id: get_tag_name - run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT - name: "Load Docker Images" id: load_images run: | diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index b2daaa4..3a0f164 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -26,15 +26,17 @@ jobs: uses: actions/download-artifact@v2 with: path: /tmp + - name: "Get Branch Name" + id: get_branch_name + run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT - name: "Load Docker Images" id: load_images run: | TAGS="" - BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) for f in $(find /tmp -type f -iname 'docker-image-*.tar' -print); do ARCH=$(echo ${f} | sed -E 's/.*docker-image-(.*).tar/\1/') docker load --input ${f} - TAG="mitchtalmadge/amp-dockerized:${BRANCH_NAME}-${ARCH}" + TAG="mitchtalmadge/amp-dockerized:${{ steps.get_branch_name.outputs.BRANCH_NAME }}-${ARCH}" TAGS="${TAGS} ${TAG}" docker tag amp-dockerized:latest ${TAG} done @@ -49,7 +51,6 @@ jobs: run: docker image push --all-tags mitchtalmadge/amp-dockerized - name: "Deploy Multi-Arch Manifest" run: | - BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) - MANIFEST="mitchtalmadge/amp-dockerized:${BRANCH_NAME}" + MANIFEST="mitchtalmadge/amp-dockerized:${{ steps.get_branch_name.outputs.BRANCH_NAME }}" docker manifest create ${MANIFEST} ${{ steps.load_images.outputs.TAGS }} docker manifest push ${MANIFEST} From e96189e25b7ab1b5f67481b00f6a432337d3af2e Mon Sep 17 00:00:00 2001 From: Mitch Talmadge <8848080+MitchTalmadge@users.noreply.github.com> Date: Fri, 10 Nov 2023 21:39:04 -0700 Subject: [PATCH 2/3] Allow input of tag name in deploy --- .github/workflows/deploy-prod.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 1b4f076..e27cbc3 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -7,7 +7,10 @@ on: tags: - v* workflow_dispatch: - + inputs: + tag: + required: true + description: e.g. v22 jobs: build: @@ -26,7 +29,12 @@ jobs: path: /tmp - name: "Get Tag Name" id: get_tag_name - run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.tag }}" != "" ]]; then + echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + else + echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + fi - name: "Load Docker Images" id: load_images run: | From 24fb27254a2566fd5c84283b97824f974733af7a Mon Sep 17 00:00:00 2001 From: Mitch Talmadge <8848080+MitchTalmadge@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:05:41 -0700 Subject: [PATCH 3/3] I blame ChatGPT --- .github/workflows/deploy-prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index e27cbc3..71359d5 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -31,9 +31,9 @@ jobs: id: get_tag_name run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.tag }}" != "" ]]; then - echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT else - echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT fi - name: "Load Docker Images" id: load_images