File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy to Amazon ECR
2
+
3
+ env :
4
+ aws_region : eu-west-2
5
+ ecr_repository : ${{ github.event.repository.name }}
6
+ dockerfile : " Dockerfile"
7
+
8
+ on :
9
+ push :
10
+ branches : [master]
11
+
12
+ jobs :
13
+ deploy :
14
+ name : Upload image to ECR
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ # ##############
18
+ # ##############
19
+ # Setup Steps #
20
+ # ##############
21
+ # ##############
22
+ - name : Checkout
23
+ uses : actions/checkout@v2
24
+
25
+ -
uses :
satackey/[email protected]
26
+ continue-on-error : true
27
+ with :
28
+ concurrency : 30
29
+
30
+ - name : Configure AWS credentials
31
+ uses : aws-actions/configure-aws-credentials@v1
32
+ with :
33
+ aws-access-key-id : ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
34
+ aws-secret-access-key : ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
35
+ aws-region : ${{ env.aws_region }}
36
+
37
+ - name : Login to Amazon ECR
38
+ id : login_to_ecr
39
+ uses : aws-actions/amazon-ecr-login@v1
40
+
41
+ # ##################
42
+ # ##################
43
+ # Build the image #
44
+ # ##################
45
+ # ##################
46
+ - name : Build and Push Docker image
47
+ env :
48
+ ECR_REGISTRY : ${{ steps.login_to_ecr.outputs.registry }}
49
+ ECR_REPOSITORY : ${{ env.ecr_repository }}
50
+ IMAGE_TAG : " ${{ github.sha }}"
51
+ DOCKERFILE : ${{ env.dockerfile }}
52
+ run : |
53
+ # Build a docker container and push it to ECR
54
+ docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f $DOCKERFILE .
55
+ docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
56
+
57
+ # Retag this as the production tag to deploy it
58
+ docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production
59
+ docker push $ECR_REGISTRY/$ECR_REPOSITORY:production
You can’t perform that action at this time.
0 commit comments