revert build-kms-image.yml to not use ko, add build_micro_service_ko action

This commit is contained in:
leongross 2022-11-28 14:15:08 +01:00
parent 248255f056
commit a578f55208
No known key found for this signature in database
GPG Key ID: 8684D89F6BF9B743
3 changed files with 111 additions and 12 deletions

View File

@ -0,0 +1,42 @@
name: Build micro service
description: Build and upload a container image for a Constellation micro-service
inputs:
name:
description: "Name of the micro-service"
required: true
koConfig:
description: "Path to the .ko.yaml config file"
required: true
koTarget:
description: "Go package to build with ko"
required: true
pushTag:
description: "Use this image tag"
required: false
githubToken:
description: "GitHub authorization token"
required: true
# Linux runner only
# TODO: Add complete tagging
runs:
using: "composite"
steps:
- name: Determine pseudo version
id: pseudo-version
uses: ./.github/actions/pseudo_version
- name: Set up ko
uses: imjasonh/setup-ko@v0.6
- name: Build and upload ko container image
id: build
env:
KO_USER: ${{ github.actor }}
KO_CONFIG_PATH: ${{ inputs.koConfig }}
KO_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
KO_DOCKER_REPO: ${{ env.REGISTRY }}/edgelesssys/constellation
GIT_REF: ${{ github.ref }}
run: |
tag=$(echo ${GIT_REF} | cut -d'/' -f3)
ko build ${{ inputs.koTarget }} --preserve-import-paths --tags ${tag}

View File

@ -0,0 +1,60 @@
name: Build and upload KMS image (KO)
env:
REGISTRY: ghcr.io
IMAGE_NAME: kmsserver
on:
workflow_dispatch:
push:
branches:
- main
- "release/**"
paths:
- "kms/**"
- "internal/constants/**"
- "internal/file/**"
jobs:
build-kms-server:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.build-and-upload.outputs.image }}
digest: ${{ steps.build-and-upload.outputs.digest }}
steps:
- name: Check out repository
id: checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
with:
ref: ${{ github.head_ref }}
- name: Setup Go environment
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # tag=v3.3.1
with:
go-version: "1.19.3"
- name: Set up ko
uses: imjasonh/setup-ko@v0.6
- name: Build and upload KMS server container image
id: build-and-upload
env:
KO_USER: ${{ github.actor }}
KO_CONFIG_PATH: ${{ github.workspace }}/.ko.yaml
KO_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
KO_DOCKER_REPO: ${{ env.REGISTRY }}/edgelesssys/constellation
GIT_REF: ${{ github.ref }}
run: |
tag=$(echo ${GIT_REF} | cut -d'/' -f3)
ko build ./kms/cmd --preserve-import-paths -t ${tag}
- name: Build and upload KMS server container image
id: build-and-upload
uses: ./.github/actions/build_micro_service_ko
with:
name: kmsserver
koConfig: .ko.yaml
koTarget: ./kms/cmd
githubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -20,9 +20,6 @@ jobs:
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.build-and-upload.outputs.image }}
digest: ${{ steps.build-and-upload.outputs.digest }}
steps:
- name: Check out repository
id: checkout
@ -35,14 +32,14 @@ jobs:
with:
go-version: "1.19.3"
- name: Set up ko
uses: imjasonh/setup-ko@v0.6
- name: Build and upload KMS server container image
id: build-and-upload
env:
KO_USER: ${{ github.actor }}
KO_CONFIG_PATH: ${{ github.workspace }}/.ko.yaml
KO_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
KO_DOCKER_REPO: ${{ env.REGISTRY }}/edgelesssys/constellation
run: ko build ./kms/cmd --preserve-import-paths -t ${{ github.sha }}
uses: ./.github/actions/build_micro_service
with:
name: kmsserver
projectVersion: "0.0.0"
dockerfile: kms/Dockerfile
githubToken: ${{ secrets.GITHUB_TOKEN }}
cosignPublicKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PUBLIC_KEY || secrets.COSIGN_DEV_PUBLIC_KEY }}
cosignPrivateKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PRIVATE_KEY || secrets.COSIGN_DEV_PRIVATE_KEY }}
cosignPassword: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PASSWORD || secrets.COSIGN_DEV_PASSWORD }}