ci: find latest image with versionsapi action

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-01-12 16:46:51 +01:00
parent 6d6ef99f11
commit 5cb10aef45
6 changed files with 38 additions and 47 deletions

View File

@ -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}."

View File

@ -1,6 +1,14 @@
name: versionsapi name: versionsapi
description: "A GitHub Action to interact with the versions API" 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: inputs:
command: command:
description: Command to run description: Command to run

View File

@ -7,6 +7,8 @@ on:
- main - main
paths: paths:
- "internal/versionsapi/**" - "internal/versionsapi/**"
- ".github/workflows/build-versionsapi-ci-image.yml"
- ".github/actions/versionsapi/**"
jobs: jobs:
build-versionsapi-ci-cli: build-versionsapi-ci-cli:
@ -24,7 +26,7 @@ jobs:
- name: Setup Go environment - name: Setup Go environment
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with: with:
go-version: "1.19.4" go-version: "1.19.5"
- name: Build and upload container image - name: Build and upload container image
uses: ./.github/actions/build_micro_service uses: ./.github/actions/build_micro_service

View File

@ -19,17 +19,24 @@ jobs:
id-token: write id-token: write
contents: read contents: read
outputs: outputs:
image: ${{ steps.find-latest-image.outputs.image }} image: ${{ steps.find-latest-image.outputs.output }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with: with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} 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 - name: Find latest image
id: find-latest-image id: find-latest-image
uses: ./.github/actions/find_latest_image uses: ./.github/actions/versionsapi
with: with:
command: latest
ref: main ref: main
stream: debug stream: debug

View File

@ -120,7 +120,7 @@ jobs:
id-token: write id-token: write
contents: read contents: read
outputs: 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 }} isDebugImage: ${{ steps.isDebugImage.outputs.isDebugImage }}
steps: steps:
- name: Check input - name: Check input
@ -147,11 +147,18 @@ jobs:
with: with:
ref: ${{ inputs.git-ref }} 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 - name: Find latest image
id: find-latest-image id: find-latest-image
if: steps.check-input.outputs.image == '' if: steps.check-input.outputs.image == ''
uses: ./.github/actions/find_latest_image uses: ./.github/actions/versionsapi
with: with:
command: latest
ref: main ref: main
stream: debug stream: debug

View File

@ -19,17 +19,24 @@ jobs:
id-token: write id-token: write
contents: read contents: read
outputs: outputs:
image: ${{ steps.find-latest-image.outputs.image }} image: ${{ steps.find-latest-image.outputs.output }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with: with:
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} 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 - name: Find latest image
id: find-latest-image id: find-latest-image
uses: ./.github/actions/find_latest_image uses: ./.github/actions/versionsapi
with: with:
command: latest
ref: main ref: main
stream: debug stream: debug