From 5cb10aef45a11f771c443c34caaa47907ac89f0d Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:46:51 +0100 Subject: [PATCH] ci: find latest image with versionsapi action Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- .github/actions/find_latest_image/action.yaml | 40 ------------------- .github/actions/versionsapi/action.yml | 8 ++++ .../workflows/build-versionsapi-ci-image.yml | 4 +- .github/workflows/e2e-test-daily.yml | 11 ++++- .github/workflows/e2e-test-manual.yml | 11 ++++- .github/workflows/e2e-test-weekly.yml | 11 ++++- 6 files changed, 38 insertions(+), 47 deletions(-) delete mode 100644 .github/actions/find_latest_image/action.yaml diff --git a/.github/actions/find_latest_image/action.yaml b/.github/actions/find_latest_image/action.yaml deleted file mode 100644 index dcc86d557..000000000 --- a/.github/actions/find_latest_image/action.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Find latest OS image -description: Finds the latest OS image of a given type. - -inputs: - ref: - description: 'Branch to search on. Can be "-" for releases or a branch name.' - required: true - default: "main" - stream: - description: 'Type of image to find. Can be one of "stable", "nightly", "debug".' - required: true - default: "debug" - -outputs: - image: - description: "The latest image of the given ref and stream." - value: ${{ steps.find-latest-image.outputs.image }} - -runs: - using: "composite" - steps: - - name: Login to AWS - uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 - with: - role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead - aws-region: eu-central-1 - - - name: Build versionsapi CLI - shell: bash - working-directory: internal/versionsapi/cli - run: go build -o versionsapi - - - name: Find latest image - id: find-latest-image - shell: bash - working-directory: internal/versionsapi/cli - run: | - image=$(./versionsapi latest --ref "${{ inputs.ref }}" --stream "${{ inputs.stream }}") - echo "image=${image}" >> "${GITHUB_OUTPUT}" - echo "Found image ${image}." diff --git a/.github/actions/versionsapi/action.yml b/.github/actions/versionsapi/action.yml index f9a2b03d5..c340faa1b 100644 --- a/.github/actions/versionsapi/action.yml +++ b/.github/actions/versionsapi/action.yml @@ -1,6 +1,14 @@ name: versionsapi description: "A GitHub Action to interact with the versions API" +# +# !!! Attention !!! +# +# Calls with command 'add' and 'remove' need synchronization. +# Don't use this action directly for these commands. +# Use the 'versionsapi' workflow instead. +# + inputs: command: description: Command to run diff --git a/.github/workflows/build-versionsapi-ci-image.yml b/.github/workflows/build-versionsapi-ci-image.yml index d9d9d5344..3d0b9c45b 100644 --- a/.github/workflows/build-versionsapi-ci-image.yml +++ b/.github/workflows/build-versionsapi-ci-image.yml @@ -7,6 +7,8 @@ on: - main paths: - "internal/versionsapi/**" + - ".github/workflows/build-versionsapi-ci-image.yml" + - ".github/actions/versionsapi/**" jobs: build-versionsapi-ci-cli: @@ -24,7 +26,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 with: - go-version: "1.19.4" + go-version: "1.19.5" - name: Build and upload container image uses: ./.github/actions/build_micro_service diff --git a/.github/workflows/e2e-test-daily.yml b/.github/workflows/e2e-test-daily.yml index 263344e00..38cc9af89 100644 --- a/.github/workflows/e2e-test-daily.yml +++ b/.github/workflows/e2e-test-daily.yml @@ -19,17 +19,24 @@ jobs: id-token: write contents: read outputs: - image: ${{ steps.find-latest-image.outputs.image }} + image: ${{ steps.find-latest-image.outputs.output }} steps: - name: Checkout uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} + - name: Login to AWS + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 + with: + role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead + aws-region: eu-central-1 + - name: Find latest image id: find-latest-image - uses: ./.github/actions/find_latest_image + uses: ./.github/actions/versionsapi with: + command: latest ref: main stream: debug diff --git a/.github/workflows/e2e-test-manual.yml b/.github/workflows/e2e-test-manual.yml index 4fd2d6591..abb04b444 100644 --- a/.github/workflows/e2e-test-manual.yml +++ b/.github/workflows/e2e-test-manual.yml @@ -120,7 +120,7 @@ jobs: id-token: write contents: read outputs: - image: ${{ steps.find-latest-image.outputs.image }}${{ steps.check-input.outputs.image }} + image: ${{ steps.find-latest-image.outputs.output }}${{ steps.check-input.outputs.image }} isDebugImage: ${{ steps.isDebugImage.outputs.isDebugImage }} steps: - name: Check input @@ -147,11 +147,18 @@ jobs: with: ref: ${{ inputs.git-ref }} + - name: Login to AWS + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 + with: + role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead + aws-region: eu-central-1 + - name: Find latest image id: find-latest-image if: steps.check-input.outputs.image == '' - uses: ./.github/actions/find_latest_image + uses: ./.github/actions/versionsapi with: + command: latest ref: main stream: debug diff --git a/.github/workflows/e2e-test-weekly.yml b/.github/workflows/e2e-test-weekly.yml index 451567287..5ae60ef3e 100644 --- a/.github/workflows/e2e-test-weekly.yml +++ b/.github/workflows/e2e-test-weekly.yml @@ -19,17 +19,24 @@ jobs: id-token: write contents: read outputs: - image: ${{ steps.find-latest-image.outputs.image }} + image: ${{ steps.find-latest-image.outputs.output }} steps: - name: Checkout uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 with: ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} + - name: Login to AWS + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 + with: + role-to-assume: arn:aws:iam::795746500882:role/GithubConstellationVersionsAPIRead + aws-region: eu-central-1 + - name: Find latest image id: find-latest-image - uses: ./.github/actions/find_latest_image + uses: ./.github/actions/versionsapi with: + command: latest ref: main stream: debug