From cf1d16b80bd5baeceaae751ca69e1bbef8493deb Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 4 Sep 2024 21:55:56 +0200 Subject: [PATCH] bundle image nightly build with limitador lastcommit Signed-off-by: Eguzki Astiz Lezaun --- .github/workflows/build-images-base.yaml | 17 +++++--- .github/workflows/build-images-branches.yaml | 8 ++-- .github/workflows/build-images-main.yaml | 11 ----- .github/workflows/build-images-scheduled.yaml | 43 +++++++++++++++++-- 4 files changed, 55 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/build-images-main.yaml diff --git a/.github/workflows/build-images-base.yaml b/.github/workflows/build-images-base.yaml index 79ea19bf..c0526fc7 100644 --- a/.github/workflows/build-images-base.yaml +++ b/.github/workflows/build-images-base.yaml @@ -8,7 +8,7 @@ on: default: 0.0.0 type: string operatorTag: - description: Operator tag + description: Operator bundle tag default: latest type: string limitadorVersion: @@ -23,6 +23,10 @@ on: description: Bundle and catalog channels, comma separated default: preview type: string + imageTags: + description: Docker image tags + default: latest + type: string workflow_dispatch: inputs: operatorVersion: @@ -30,7 +34,7 @@ on: default: 0.0.0 type: string operatorTag: - description: Operator tag + description: Operator bundle tag default: latest type: string limitadorVersion: @@ -47,7 +51,7 @@ on: type: string env: - IMG_TAGS: ${{ inputs.operatorTag }} + IMG_TAGS: ${{ inputs.imageTags || inputs.operatorTag }} VERSION: ${{ inputs.operatorVersion }} IMG_REGISTRY_HOST: quay.io IMG_REGISTRY_ORG: kuadrant @@ -60,7 +64,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install qemu dependency run: | sudo apt-get update @@ -106,7 +110,7 @@ jobs: go-version: 1.21.x id: go - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install qemu dependency run: | sudo apt-get update @@ -118,7 +122,6 @@ jobs: REGISTRY=${{ env.IMG_REGISTRY_HOST }} \ ORG=${{ env.IMG_REGISTRY_ORG }} \ VERSION=${{ env.VERSION }} \ - IMAGE_TAG=${{ inputs.operatorTag }} \ LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \ REPLACES_VERSION=${{ inputs.replacesVersion }} \ CHANNELS=${{ inputs.channels }} @@ -160,7 +163,7 @@ jobs: go-version: 1.21.x id: go - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Generate Catalog Content run: | make catalog \ diff --git a/.github/workflows/build-images-branches.yaml b/.github/workflows/build-images-branches.yaml index 133f1f22..47559265 100644 --- a/.github/workflows/build-images-branches.yaml +++ b/.github/workflows/build-images-branches.yaml @@ -1,15 +1,17 @@ -name: Build images for dev branches +name: Build images for branches on: push: branches: ['*'] + workflow_dispatch: {} jobs: workflow-build: - if: github.ref_name != 'main' && !startsWith(github.ref, 'refs/tags/v') name: Calls build-images-base workflow uses: ./.github/workflows/build-images-base.yaml secrets: inherit with: - operatorVersion: ${{ github.ref_name }} + operatorVersion: 0.0.0 operatorTag: ${{ github.ref_name }} + limitadorVersion: latest + imageTags: ${{ github.ref_name }} diff --git a/.github/workflows/build-images-main.yaml b/.github/workflows/build-images-main.yaml deleted file mode 100644 index 587e8a84..00000000 --- a/.github/workflows/build-images-main.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: Build images for main branch - -on: - push: - branches: ['main'] - -jobs: - workflow-build: - name: Calls build-images-base workflow - uses: ./.github/workflows/build-images-base.yaml - secrets: inherit diff --git a/.github/workflows/build-images-scheduled.yaml b/.github/workflows/build-images-scheduled.yaml index e58df201..3914dbe2 100644 --- a/.github/workflows/build-images-scheduled.yaml +++ b/.github/workflows/build-images-scheduled.yaml @@ -3,13 +3,50 @@ name: Schedule build with latest image SHA versions on: schedule: - cron: '0 0 * * 0' + workflow_dispatch: {} jobs: + release-date: + name: GetDate + runs-on: ubuntu-latest + outputs: + release_date: ${{ steps.release_date.outputs.release_date }} + steps: + - id: release_date + run: echo "release_date=nightly-$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT + limitador-latest-revision: + name: Get the latest git commit from limitador in the default branch + runs-on: ubuntu-latest + outputs: + limitador_last_hash: ${{ steps.lastcommit.outputs.hash }} + steps: + - id: lastcommit + uses: nmbgeek/github-action-get-latest-commit@v0.1.0 + with: + repository: Kuadrant/limitador + # avoid the action failing due to API rate limiting + token: ${{ secrets.GITHUB_TOKEN }} + - name: Print Limitador's last commit revision + run: echo "${{ steps.lastcommit.outputs.hash }}" + check-limitador-image: + needs: limitador-latest-revision + name: Check limitador image exists + runs-on: ubuntu-latest + steps: + - name: Check image + uses: cloudposse/github-action-docker-image-exists@0.2.0 + with: + registry: quay.io + organization: kuadrant + repository: limitador + tag: ${{ needs.limitador-latest-revision.outputs.limitador_last_hash }} workflow-build: + needs: [release-date, check-limitador-image, limitador-latest-revision] name: Calls build-images-base workflow uses: ./.github/workflows/build-images-base.yaml secrets: inherit with: - operatorVersion: ${{ github.sha }} - operatorTag: ${{ github.sha }} - limitadorVersion: ${{ vars.LIMITADOR_SHA }} + operatorVersion: 0.0.0 + imageTags: ${{ needs.release-date.outputs.release_date }} nightly-latest + operatorTag: ${{ needs.release-date.outputs.release_date }} + limitadorVersion: ${{ needs.limitador-latest-revision.outputs.limitador_last_hash }}