Skip to content

KBS Build and Push API & Web #9

KBS Build and Push API & Web

KBS Build and Push API & Web #9

Workflow file for this run

name: KBS Build and Push API & Web
permissions:
id-token: write
contents: write
on:
workflow_dispatch:
inputs:
create_kbs_web:
description: 'KBS Web'
required: false
type: boolean
create_kbs_api:
description: 'KBS API'
required: false
type: boolean
kbs-web-version-tag:
description: 'KBS Web version Tag'
required: true
default: 'latest'
kbs-api-version-tag:
description: 'KBS API version Tag'
required: true
default: 'latest'
jobs:
Docker:
name: Build and Push KBS Docker Images
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: arn:aws:iam::500447081210:role/github-oidc-Role-MCT2KM9AM6YN
role-session-name: KBS_GitAction
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push the API to ECR
if: ${{ github.event.inputs.create_kbs_api == 'true' }}
id: build-push-API
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: kbs-api
IMAGE_TAG: ${{ github.event.inputs.kbs-api-version-tag }}
run: |
# Build the API docker container and push it to ECR
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} -f Dockerfile-api .
echo "Pushing image to ECR..."
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
echo "::set-output name=image::${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
- name: Build, tag, and push the Web to ECR
if: ${{ github.event.inputs.create_kbs_web == 'true' }}
id: build-push-Web
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: kbs-web
IMAGE_TAG: ${{ github.event.inputs.kbs-web-version-tag }}
run: |
# Build the Web docker container and push it to ECR
docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} -f Dockerfile-web .
echo "Pushing image to ECR..."
docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
echo "::set-output name=image::${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT