From 43d91f736420f3cae4421fe4425088e897ee78bb Mon Sep 17 00:00:00 2001 From: Moritz Sanft <58110325+msanft@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:16:53 +0100 Subject: [PATCH] separate action for finding image version Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> --- .github/actions/find_latest_image/action.yml | 69 ++++++++++++++++++++ .github/workflows/e2e-test-tf-module.yml | 26 ++++---- .github/workflows/e2e-test.yml | 58 ++-------------- 3 files changed, 90 insertions(+), 63 deletions(-) create mode 100644 .github/actions/find_latest_image/action.yml diff --git a/.github/actions/find_latest_image/action.yml b/.github/actions/find_latest_image/action.yml new file mode 100644 index 00000000000..d18a0a207ee --- /dev/null +++ b/.github/actions/find_latest_image/action.yml @@ -0,0 +1,69 @@ +name: Find latest image +description: 'Find the latest image reference for a given ref/stream.' + +inputs: + git-ref: + description: 'Git ref to checkout.' + imageVersion: + description: 'Image version to use. If set, no image will be searched for and the specified image will be returned.' + ref: + description: 'The ref the image was built on. (e.g. "main")' + default: 'main' + stream: + description: 'The publication stream of the image. (e.g. "debug")' + default: 'debug' + +outputs: + image: + description: "Image reference to be used in the cluster." + value: ${{ steps.find-latest-image.outputs.output }}${{ steps.check-input.outputs.image }} + isDebugImage: + description: "Whether the image is a debug image." + value: ${{ steps.isDebugImage.outputs.isDebugImage }} + +runs: + using: 'composite' + steps: + - name: Checkout head + if: inputs.imageVersion == '' && inputs.git-ref == 'head' + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} + + - name: Checkout ref + if: inputs.imageVersion == '' && inputs.git-ref != 'head' + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + ref: ${{ inputs.git-ref }} + + - name: Login to AWS + if: inputs.imageVersion == '' + uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1 + with: + role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead + aws-region: eu-central-1 + + - name: Find latest image + id: find-latest-image + if: inputs.imageVersion == '' + uses: ./.github/actions/versionsapi + with: + command: latest + ref: main + stream: debug + + - name: Is debug image? + id: isDebugImage + shell: bash + run: | + case "${{ inputs.imageVersion }}" in + "") + echo "isDebugImage=true" | tee -a "$GITHUB_OUTPUT" + ;; + *"/stream/debug/"*) + echo "isDebugImage=true" | tee -a "$GITHUB_OUTPUT" + ;; + *) + echo "isDebugImage=false" | tee -a "$GITHUB_OUTPUT" + ;; + esac diff --git a/.github/workflows/e2e-test-tf-module.yml b/.github/workflows/e2e-test-tf-module.yml index 1d814b80327..fb6e5211a60 100644 --- a/.github/workflows/e2e-test-tf-module.yml +++ b/.github/workflows/e2e-test-tf-module.yml @@ -6,7 +6,6 @@ on: ref: type: string description: "Git ref to checkout" - required: false cloudProvider: description: "Which cloud provider to use." type: choice @@ -20,20 +19,16 @@ on: type: string required: true image: - description: "Node image version of the cluster." + description: "Node image reference which is compatible with the current dev release version. If not set, the latest debug image from main is used." type: string - required: true cliVersion: description: "Constellation CLI version to use. Empty value means build from source." type: string - default: "" - required: false workflow_call: inputs: ref: type: string description: "Git ref to checkout" - required: false cloudProvider: description: "Which cloud provider to use." type: string @@ -43,14 +38,11 @@ on: type: string required: true image: - description: "Node image reference which is compatible with the current dev release version." + description: "Node image reference which is compatible with the current dev release version. If not set, the latest debug image from main is used." type: string - required: true cliVersion: description: "Constellation CLI version to use. Empty value means build from source." type: string - default: "" - required: false jobs: build: runs-on: ubuntu-22.04 @@ -84,15 +76,25 @@ jobs: last_three="${run_id: -3}" echo "prefix=e2e-${last_three}-${{ github.run_attempt }}" | tee -a "$GITHUB_OUTPUT" + - name: Find Latest Image + id: find-latest-image + uses: .github/actions/find_latest_image + with: + git-ref: ${{ inputs.ref }} + imageVersion: ${{ inputs.image }} + ref: main + stream: debug + - name: Create AWS Terraform variable input file if: inputs.cloudProvider == 'aws' working-directory: ./terraform-module/aws-constellation run: | cat > terraform.tfvars <