Skip to content

Create CI pipeline to push api docker image to ecr #15

Create CI pipeline to push api docker image to ecr

Create CI pipeline to push api docker image to ecr #15

Workflow file for this run

name: Push to ECR
'on':
- push
jobs:
build:
name: Push to ECR
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: '${{ secrets.AWS_ACCESS_KEY_ID }}'
aws-secret-access-key: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
aws-region: us-east-1
- name: Get ECR Repository URI
id: fetch-ecr-repo
run: |
export REPOSITORY_URI=$(aws ssm get-parameter --name "/config/observation-tracker/repository.uri" --with-decryption --query Parameter.Value --output text)
echo "::set-output name=repository_uri::$REPOSITORY_URI"
- name: Login to Amazon ECR
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: 'Build, tag, and push image to Amazon ECR'
env:
IMAGE_TAG: '${{ github.sha }}'
working-directory: api/
run: |
echo ${{ steps.fetch-ecr-repo.outputs.repository_uri }}
docker build -t ${{ steps.fetch-ecr-repo.outputs.repository_uri }}:$IMAGE_TAG .
docker push ${{ steps.fetch-ecr-repo.outputs.repository_uri }}:$IMAGE_TAG