Skip to content

Commit

Permalink
github action: replace image_name with service_name
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed May 23, 2024
1 parent 7842f8d commit a20a95f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Build and push Docker image"
run-name: "Publish image: ${{inputs.image_name}} ${{inputs.image_tag}}"
run-name: "Publish image ${{inputs.image_tag}} for ${{inputs.service_name}}"

on:
workflow_dispatch:
Expand All @@ -9,17 +9,17 @@ on:
required: true
type: string
default: '02-household-queries'
image_name:
description: 'Name of the image and prefix of service'
required: true
type: choice
options:
- 'chainlit-chatbot'
image_tag:
description: 'Tag/Version of the image to push'
required: true
type: string
default: '0.01'
service_name:
description: 'Name of target AWS service'
required: true
type: choice
options:
- 'secure-chatbot-svc'
build_image:
description: "Build and push image"
required: true
Expand All @@ -31,11 +31,11 @@ on:
type: boolean
default: 'false'

env:
IMAGE_NAME: ${{ inputs.service_name }}

jobs:
publish-image:
env:
# Target path where the image will be pushed, i.e., to GHCR for the current repo
GHCR_PATH: "ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }}:${{ inputs.image_tag }}"
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
Expand All @@ -58,27 +58,28 @@ jobs:
if: inputs.build_image
uses: actions/checkout@v4

- name: "Build image ${{ inputs.image_name }} with tag '${{ inputs.image_tag }}'"
- name: "Build image with tag '${{ inputs.image_tag }}'"
if: inputs.build_image
run: |
cd ${{ inputs.dockerfile_folder }}
# TODO: make this more easily editable and secure
# The DOT_ENV_FILE_CONTENTS contains OPENAI_API_KEY, RETRIEVE_K, LLM_MODEL_NAME, SUMMARIZER_LLM_MODEL_NAME
echo "${{secrets.DOT_ENV_FILE_CONTENTS}}" > .env
docker build -t "${{ inputs.image_name }}:${{ inputs.image_tag }}" --build-arg GURU_CARDS_URL="https://docs.google.com/uc?export=download&id=${{ secrets.GURU_CARDS_URL_ID }}" .
docker build -t "$IMAGE_NAME:${{ inputs.image_tag }}" --build-arg GURU_CARDS_URL="https://docs.google.com/uc?export=download&id=${{ secrets.GURU_CARDS_URL_ID }}" .
- name: "Publish image to AWS ECR'"
if: inputs.build_image
env:
ECR_PATH: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}
run: |
echo "# Publishing image ${{ inputs.image_name }}:${{ inputs.image_tag }} to $ECR_PATH"
echo "# Publishing image ${{ inputs.image_tag }} to $ECR_PATH"
docker tag "${{ inputs.image_name }}:${{ inputs.image_tag }}" "$ECR_PATH:${{ inputs.image_tag }}"
docker tag "$IMAGE_NAME:${{ inputs.image_tag }}" "$ECR_PATH:${{ inputs.image_tag }}"
docker push "$ECR_PATH:${{ inputs.image_tag }}"
- name: "Update AWS Service"
if: inputs.deploy_image
env:
CLUSTER_NAME: genai-experiments
SERVICE_NAME: ${{ inputs.image_name }}-service
run: |
aws ecs update-service --force-new-deployment --cluster "$CLUSTER_NAME" --service "$SERVICE_NAME"
aws ecs update-service --force-new-deployment --cluster "$CLUSTER_NAME" --service "${{ inputs.service_name }}"

0 comments on commit a20a95f

Please sign in to comment.