From bf4683a51fa89f319ac930569352054dcc6d35e8 Mon Sep 17 00:00:00 2001 From: blakep7 Date: Wed, 2 Aug 2023 13:49:10 -0700 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b607d171..1e43eee40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,12 @@ on: description: 'Version of ESS Image to be released, with build number' required: true type: string + IS_LATEST: + description: 'Should we push the latest Dockerhub tags and mark releases as latest' + required: true + type: boolean + default: true + env: DOCKERHUB_REGISTRY: ${{ vars.DOCKERHUB_REPO }} @@ -70,6 +76,7 @@ jobs: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + # Check if Release Already Exists and fail so there is not an error when attempting to create the same release - name: Check if Release Already Exists for Requested Version run: | RELEASE_STATUS=$( @@ -136,13 +143,14 @@ jobs: docker push ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} ${DOCKERHUB_REGISTRY}/${image}:latest docker push ${DOCKERHUB_REGISTRY}/${image}:latest fi done shell: bash + # Get and promote the Dockerhub images that contain our packages for backup purposes - name: Get and Promote Package Artifacts to Dockerhub if: matrix.image-version == 'AGBOT_VERSION' run: | @@ -174,7 +182,7 @@ jobs: docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest fi @@ -182,7 +190,7 @@ jobs: # If the packages do not exist as artifacts we want to simply fallback to dockerhub and if we are on master then tie the latest release to that package elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION}; then echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest fi @@ -215,7 +223,7 @@ jobs: docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest fi @@ -223,7 +231,7 @@ jobs: # If the packages do not exist as artifacts we want to simply fallback to dockerhub and if we are on master then tie the latest release to that package elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION}; then echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest fi @@ -255,14 +263,14 @@ jobs: docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest fi elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION}; then echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." - if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + if [[ "${{ github.event.inputs.IS_LATEST }}" == "true" ]]; then docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest fi @@ -303,7 +311,7 @@ jobs: runs-on: ubuntu-20.04 steps: - # Get Packages + # Get the packages to be included in the release, we try to get them from the build-push.yml workflow artifacts and if they don't exist there we will attempt to get them from the dockerhub backups - name: Get Packages & Files from Build Workflow Artifacts run: | mkdir -p $RUNNER_TEMP/release_files/upload && cd $RUNNER_TEMP/release_files