Skip to content

Instantly share code, notes, and snippets.

@abh006
Last active January 12, 2022 19:50
Show Gist options
  • Save abh006/8924b3eb2df0557f95817804f7f2b964 to your computer and use it in GitHub Desktop.
Save abh006/8924b3eb2df0557f95817804f7f2b964 to your computer and use it in GitHub Desktop.
Github Actions Files - Amazon ECR
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- 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-2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
id: login-ecr
- uses: actions/checkout@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: <repository-name>
IMAGE_TAG: ${{ github.sha }} # or any tag name
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment