Skip to content

Commit

Permalink
Merge pull request #17 from KeyValueSoftwareSystems/add/ci-public-ecr…
Browse files Browse the repository at this point in the history
…-push

Add: public ecr push step in CI
  • Loading branch information
Ujjwal048 authored May 27, 2024
2 parents 714f1c1 + 6dc13a4 commit 8a27539
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/ci-server-.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
ECR_REPOSITORY: ${{ steps.set_env.outputs.ECR_REPOSITORY }}
ENVIRONMENT_BUCKET: ${{ steps.set_env.outputs.ENVIRONMENT_BUCKET }}
SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }}
PUBLIC_CONDUCTOR_ECR: ${{ steps.vars.outputs.PUBLIC_CONDUCTOR_ECR}}

steps:
- id: vars
Expand All @@ -48,7 +49,7 @@ jobs:
case $BRANCH in
"dev")
ENV="dev"
;;
;;
"stg")
ENV="stg"
;;
Expand All @@ -75,6 +76,7 @@ jobs:
echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT
echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT
echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT
echo "PUBLIC_CONDUCTOR_ECR=sandbox-conductor-server" >> $GITHUB_OUTPUT
else
echo "Branch not configured!"
exit 1
Expand Down Expand Up @@ -108,6 +110,7 @@ jobs:
ECR_REPOSITORY: ${{needs.prepare-env.outputs.ECR_REPOSITORY}}
ENVIRONMENT_BUCKET: ${{needs.prepare-env.outputs.ENVIRONMENT_BUCKET}}
IMAGE_TAG: ${{ github.event.inputs.tag }}
PUBLIC_CONDUCTOR_ECR: ${{needs.prepare-env.outputs.PUBLIC_CONDUCTOR_ECR}}
outputs:
ECR_REPO: ${{ steps.build.outputs.ECR_REPO }}
APP_IMAGE: ${{ steps.image.outputs.APP_IMAGE }}
Expand Down Expand Up @@ -151,6 +154,35 @@ jobs:
platforms: linux/amd64
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}

- name: Configure AWS credentials for Public ECR
if: ${{ env.ENV == 'dev'}}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets[env.AWS_ROLE] }}
aws-region: us-east-1

- name: Login to Amazon ECR Public
if: ${{ env.ENV == 'dev'}}
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- name: Build and push to Public ECR
if: ${{ env.ENV == 'dev'}}
id: build-public
uses: docker/[email protected]
env:
PUBLIC_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
PUBLIC_REGISTRY_ALIAS: kvsiren-${{ env.ENV }}
with:
context: .
file: ./Dockerfile
push: true
provenance: false
platforms: linux/amd64
tags: ${{ env.PUBLIC_REGISTRY }}/${{ env.PUBLIC_REGISTRY_ALIAS }}/${{ env.PUBLIC_CONDUCTOR_ECR }}:${{ env.IMAGE_TAG }}

- name: Image name
id: image
env:
Expand Down

0 comments on commit 8a27539

Please sign in to comment.