-
Notifications
You must be signed in to change notification settings - Fork 98
47 lines (40 loc) · 1.39 KB
/
aws_ecr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Push Docker image to Amazon ECR
on:
release:
types:
- edited
- released
branches:
- master
jobs:
build-and-push:
name: Build and Push Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- id: get_version
name: Get version
uses: jannemattila/get-version-from-tag@v3
- 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-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
ECR_REPOSITORY: 'crispresso2'
AWS_REGION: 'us-east-1'
IMAGE_TAG: v${{ steps.get_version.outputs.version }}
run: |
# Build a docker container and push it to ECR
docker build -t $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG .
echo "Pushing image to ECR..."
docker push $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG"