From a20a95f5d99fcb3ff5c13baeaf0d0dd1027ff084 Mon Sep 17 00:00:00 2001 From: Yoom Lam Date: Thu, 23 May 2024 10:10:07 -0500 Subject: [PATCH] github action: replace image_name with service_name --- .github/workflows/push-image.yml | 33 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/push-image.yml b/.github/workflows/push-image.yml index 59bc5fc..1c7d2ad 100644 --- a/.github/workflows/push-image.yml +++ b/.github/workflows/push-image.yml @@ -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: @@ -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 @@ -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 @@ -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 }}"