diff --git a/.github/workflows/auto-pr-ci.yaml b/.github/workflows/auto-pr-ci.yaml index 02545d55f..041818cb4 100644 --- a/.github/workflows/auto-pr-ci.yaml +++ b/.github/workflows/auto-pr-ci.yaml @@ -20,7 +20,6 @@ env: KUBESPRAY_IMAGE_NAME: kubespray SPRAY_JOB_IMAGE_NAME: spray-job AIRGAP_PATCH_IMAGE_NAME: airgap-patch - KUBESPRAY_TAG: latest jobs: get_ref: @@ -90,19 +89,21 @@ jobs: contents: read steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ needs.get_ref.outputs.ref }} + - name: Set env run: | ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} + echo "KUBESPRAY_TAG=$(git tag | tail -1)" >> ${GITHUB_ENV} - name: Echo env run: | echo "REPO: ${{ env.REPO }}" - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ needs.get_ref.outputs.ref }} + echo "KUBESPRAY_TAG: ${{ env.KUBESPRAY_TAG }}" - name: Log in to registry # This is where you will update the PAT to GITHUB_TOKEN @@ -139,7 +140,7 @@ jobs: docker push $IMAGE_ID:$VERSION - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=${{ env.KUBESPRAY_TAG }} - name: spray-job Push image run: | @@ -154,7 +155,7 @@ jobs: docker push $IMAGE_ID:$VERSION - name: airgap-patch Build image - run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=${{ env.KUBESPRAY_TAG }} - name: airgap-patch Push image run: | diff --git a/.github/workflows/build-push-for-e2e.yml b/.github/workflows/build-push-for-e2e.yml index 44192430b..5951df8ce 100644 --- a/.github/workflows/build-push-for-e2e.yml +++ b/.github/workflows/build-push-for-e2e.yml @@ -9,7 +9,6 @@ env: KUBESPRAY_IMAGE_NAME: kubespray SPRAY_JOB_IMAGE_NAME: spray-job AIRGAP_PATCH_IMAGE_NAME: airgap-patch - KUBESPRAY_TAG: latest jobs: build-push-for-e2e: @@ -19,19 +18,21 @@ jobs: contents: read steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ needs.get_ref.outputs.ref }} + - name: Set env run: | ORGANIZATION_NAME=$(echo ${GITHUB_REPOSITORY}| awk -F "/" '{print $1}') echo "REPO=${ORGANIZATION_NAME,,}" >> ${GITHUB_ENV} + echo "KUBESPRAY_TAG=$(git tag | tail -1)" >> ${GITHUB_ENV} - name: Echo env run: | echo "REPO: ${{ env.REPO }}" - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ needs.get_ref.outputs.ref }} + echo "KUBESPRAY_TAG: ${{ env.KUBESPRAY_TAG }}" - name: Log in to registry # This is where you will update the PAT to GITHUB_TOKEN @@ -68,7 +69,7 @@ jobs: docker push $IMAGE_ID:$VERSION - name: spray-job Build image - run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + run: docker build . --file ./build/images/$SPRAY_JOB_IMAGE_NAME/Dockerfile --tag $SPRAY_JOB_IMAGE_NAME --build-arg SPRAY_TAG=${{ env.KUBESPRAY_TAG }} - name: spray-job Push image run: | @@ -83,7 +84,7 @@ jobs: docker push $IMAGE_ID:$VERSION - name: airgap-patch Build image - run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=$KUBESPRAY_TAG + run: docker build . --file ./build/images/$AIRGAP_PATCH_IMAGE_NAME/Dockerfile --tag $AIRGAP_PATCH_IMAGE_NAME --build-arg SPRAY_TAG=${{ env.KUBESPRAY_TAG }} - name: airgap-patch Push image run: | diff --git a/.github/workflows/call-build-imgs-for-spray.yaml b/.github/workflows/call-build-imgs-for-spray.yaml index 11a50054e..cb7116f87 100644 --- a/.github/workflows/call-build-imgs-for-spray.yaml +++ b/.github/workflows/call-build-imgs-for-spray.yaml @@ -89,6 +89,5 @@ jobs: platforms: linux/amd64,linux/arm64 tags: | ghcr.io/${{ inputs.REPO }}/kubespray:${{ needs.output-variable.outputs.image_tag_short_sha }} - ghcr.io/${{ inputs.REPO }}/kubespray:latest cache-from: type=gha cache-to: type=gha,mode=max