Skip to content

Commit

Permalink
add step: Update AWS Service
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed May 17, 2024
1 parent 6366b67 commit 07ec406
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: "Build and publish Docker image"
name: "Build and push Docker image"
run-name: "Publish image: ${{inputs.image_name}} ${{inputs.image_tag}}"

# SecRel will not sign images outside the scope of the repository that's calling SecRel,
# so the image must exist in abd-vro-internal for SecRel to sign the images (required for sandbox and prod environments).
# Run this in action in both abd-vro and abd-vro-internal repos.

on:
workflow_dispatch:
inputs:
Expand All @@ -17,12 +13,22 @@ on:
description: 'Name of the image to push'
required: true
type: string
default: 'chainlit_bot'
default: 'chainlit-chatbot'
image_tag:
description: 'Tag/Version of the image to push'
required: true
type: string
default: '0.01'
build_image:
description: "Build and push image"
required: true
type: boolean
default: 'true'
deploy_image:
description: "Deploy image"
required: true
type: boolean
default: 'false'

# env:
# Target path where the image will be pushed, i.e., to GHCR for the current repo
Expand All @@ -49,24 +55,29 @@ jobs:
mask-password: true

- name: "Checkout source code"
if: ${{ inputs.build_image == 'true' }}
uses: actions/checkout@v4

- name: Set up Docker Buildx for build-push-action
if: ${{ inputs.build_image == 'true' }}
uses: docker/setup-buildx-action@v3
# with:
# version: latest
# driver-opts: image=moby/buildkit:latest

- name: Login to Docker Hub for build-push-action
- name: "Login to Docker Hub for build-push-action"
if: ${{ inputs.build_image == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Push Docker image
- name: "Build Docker image"
id: build
if: ${{ inputs.build_image == 'true' }}
uses: docker/build-push-action@v5
env:
ECR_PATH: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}
# env:
# ECR_PATH: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}
with:
context: ${{ inputs.dockerfile_folder }}
tags: "${{ inputs.image_name }}:${{ inputs.image_tag }}"
Expand All @@ -77,7 +88,7 @@ jobs:
# cache-to: type=registry,ref=${{ env.ECR_PATH }}:dockercache,mode=max,image-manifest=true

- name: "Publish image ${{ inputs.image_name }} with tag '${{ inputs.image_tag }}'"
id: docker-push
if: ${{ steps.build.outcome == 'success' }}
shell: bash
env:
ECR_PATH: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPO }}
Expand All @@ -87,3 +98,11 @@ jobs:
docker tag "${{ inputs.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 == 'true' }}
shell: bash
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"

0 comments on commit 07ec406

Please sign in to comment.