From c5d8db410f011984b8df8cb200a83fd632227aef Mon Sep 17 00:00:00 2001 From: Jay Rogers Date: Tue, 14 Jan 2025 12:44:44 -0600 Subject: [PATCH] Enhance GitHub Actions workflows to fetch latest release tags for beta and production images. Updated cron schedule for production images and added ref input for Docker build and publish service. --- .../workflows/action_publish-images-beta.yml | 12 ++++++++++++ .../action_publish-images-production.yml | 17 +++++++++++++++-- .../service_docker-build-and-publish.yml | 10 +++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/action_publish-images-beta.yml b/.github/workflows/action_publish-images-beta.yml index b521006..5045c61 100644 --- a/.github/workflows/action_publish-images-beta.yml +++ b/.github/workflows/action_publish-images-beta.yml @@ -5,8 +5,20 @@ on: release: types: [prereleased] jobs: + get-latest-beta-release: + runs-on: ubuntu-24.04 + outputs: + release_tag: ${{ steps.get_latest_beta.outputs.release_tag }} + steps: + - name: Get Latest Beta Release + id: get_latest_beta + run: | + LATEST_BETA=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases | jq -r '[.[] | select(.prerelease == true)][0].tag_name') + echo "release_tag=${LATEST_BETA}" >> $GITHUB_OUTPUT + build-beta-images: uses: ./.github/workflows/service_docker-build-and-publish.yml secrets: inherit with: release_type: 'beta' + ref: ${{ needs.get-latest-beta-release.outputs.release_tag }} diff --git a/.github/workflows/action_publish-images-production.yml b/.github/workflows/action_publish-images-production.yml index dd1afa2..01b3de7 100644 --- a/.github/workflows/action_publish-images-production.yml +++ b/.github/workflows/action_publish-images-production.yml @@ -5,11 +5,24 @@ on: release: types: [released] schedule: - - cron: '0 8 * * 2' + - cron: '0 4 * * 2' jobs: + get-latest-release: + runs-on: ubuntu-24.04 + outputs: + release_tag: ${{ steps.get_latest_release.outputs.release_tag }} + steps: + - name: Get Latest Release + id: get_latest_release + run: | + LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name) + echo "release_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT + build-production-images: + needs: get-latest-release uses: ./.github/workflows/service_docker-build-and-publish.yml secrets: inherit with: - release_type: 'latest' \ No newline at end of file + release_type: 'latest' + ref: ${{ needs.get-latest-release.outputs.release_tag }} \ No newline at end of file diff --git a/.github/workflows/service_docker-build-and-publish.yml b/.github/workflows/service_docker-build-and-publish.yml index 63ea3f3..91fc0d7 100644 --- a/.github/workflows/service_docker-build-and-publish.yml +++ b/.github/workflows/service_docker-build-and-publish.yml @@ -8,6 +8,10 @@ on: required: true description: 'Release type (latest, beta, edge, dev, etc)' default: 'edge' + ref: + type: string + default: ${{ github.ref }} + description: 'The git ref to checkout (branch, tag, or commit SHA)' jobs: setup-matrix: @@ -17,7 +21,9 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 - + with: + ref: ${{ inputs.ref }} + - name: Assemble Ansible versions into the matrix 😎 id: get-ansible-versions run: | @@ -34,6 +40,8 @@ jobs: steps: - name: Check out code. uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} - name: Login to DockerHub uses: docker/login-action@v3