-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 1.46 KB
/
push.yaml
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
48
49
50
51
52
name: push to ECR
on:
push:
paths:
- "easypay-app/**"
jobs:
# This workflow has two jobs call check and push
# check --> checks the branch that the push happened on
check:
name: Pre-check
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.ref_branch }}
steps:
- name: Get branch
id: branch
uses: tj-actions/branch-names@v6
# push --> pushes the app to AWS ECR
push:
name: push to ECR
runs-on: ubuntu-latest
needs: check
if: ${{ needs.check.outputs.branch }} == "main"
steps:
# Steps in this push job
- name: Check out code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
working-directory: ./easypay-app
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: easypay-repo
IMAGE_TAG: latest # ${{ github.sha }} will use this in the future
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG