Skip to content

Commit

Permalink
Add deploy to Amazon ECR workflow (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Nov 9, 2020
1 parent 25278d2 commit 93eb35b
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy to Amazon ECR

env:
aws_region: eu-west-2
ecr_repository: ${{ github.event.repository.name }}
dockerfile: "Dockerfile"

on:
push:
branches: [master]

jobs:
deploy:
name: Upload image to ECR
runs-on: ubuntu-latest
steps:
###############
###############
# Setup Steps #
###############
###############
- name: Checkout
uses: actions/checkout@v2

- uses: satackey/[email protected]
continue-on-error: true
with:
concurrency: 30

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
aws-region: ${{ env.aws_region }}

- name: Login to Amazon ECR
id: login_to_ecr
uses: aws-actions/amazon-ecr-login@v1

###################
###################
# Build the image #
###################
###################
- name: Build and Push Docker image
env:
ECR_REGISTRY: ${{ steps.login_to_ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ecr_repository }}
IMAGE_TAG: "${{ github.sha }}"
DOCKERFILE: ${{ env.dockerfile }}
run: |
# Build a docker container and push it to ECR
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f $DOCKERFILE .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# Retag this as the production tag to deploy it
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production

0 comments on commit 93eb35b

Please sign in to comment.