Skip to content

aws-ecr-login credentials fix maby #4

aws-ecr-login credentials fix maby

aws-ecr-login credentials fix maby #4

name: deploy-on-aws
on:
push:
branches:
- main
jobs:
push_to_ecr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2 # allow the runner to access the code in the repository
- name: Login to Amazon ECR
id: login-ecr # needed to reference this step later in the workflow
uses: aws-actions/amazon-ecr-login@v1
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: 324-devops-refcard-03
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG