Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
blakep7 committed Aug 2, 2023
1 parent 4d48d5d commit bf4683a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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=$(
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -174,15 +182,15 @@ 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
# 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
Expand Down Expand Up @@ -215,15 +223,15 @@ 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
# 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bf4683a

Please sign in to comment.