-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ECR and Docker Hub docker push workflow (#4)
Signed-off-by: Arthur Diniz <arthurbdiniz@gmail.com>
- Loading branch information
1 parent
416695a
commit f209719
Showing
1 changed file
with
36 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,36 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
push_to_ecr: | ||
name: Push Docker image to ECR | ||
runs-on: ubuntu-latest | ||
container: dnxsolutions/aws:2.1.6-dnx1 | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
- 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: us-east-1 | ||
- name: Get the tag | ||
id: get_tag | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} | ||
- name: Build, tag, and push image to Amazon public ECR | ||
env: | ||
ECR_REGISTRY: public.ecr.aws | ||
ECR_REPOSITORY: v9i6s3d6/terraform | ||
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }} | ||
run: | | ||
apk add docker | ||
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest |