-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fc8445
commit 63b9fe9
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Deploy image to AWS ECR | ||
|
||
# Run this workflow every time a new tag is created | ||
on: | ||
create: | ||
tags: | ||
- .* | ||
jobs: | ||
ecr: | ||
# Name the Job | ||
name: build and deploy image to AWS ECR | ||
# Set the type of machine to run on | ||
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: ap-south-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set Tag Number | ||
id: tag-number | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | ||
- name: Check Tag Release | ||
env: | ||
RELEASE_VERSION: ${{ steps.tag-number.outputs.tag }} | ||
run: | | ||
echo $RELEASE_VERSION | ||
echo ${{ steps.vars.outputs.tag }} | ||
- name: Build, tag, and push image to Amazon ECR | ||
env: | ||
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} | ||
ECR_REPOSITORY: demo | ||
IMAGE_TAG: ${{ steps.tag-number.outputs.tag }} | ||
run: | | ||
docker build -t demo . | ||
docker tag demo:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||