-
Notifications
You must be signed in to change notification settings - Fork 25
67 lines (53 loc) · 2.04 KB
/
build-push-ecr.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
53
54
55
56
57
58
59
60
61
62
63
64
name: Build and Push
on:
push:
tags: [ 'v*' ]
pull_request:
branches: [ "main" ]
env:
Dockerfile_Backend: Dockerfile
Dockerfile_Web: web/Dockerfile
jobs:
build:
runs-on: warp-ubuntu-latest-x64-16x-spot
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
- name: Setup AWS Creds
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY_AWS }}
aws-secret-access-key: ${{ secrets.SECRET_KEY_AWS }}
aws-region: us-west-2
- name: login ECR
if: github.event_name != 'pull_request'
id: ecr-login
uses: aws-actions/amazon-ecr-login@v1
- name: Build Backend and and push
if: github.event_name != 'pull_request'
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.BACKEND_ECR_REPOSITORY }}
run: |
VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3)
TAG=$ECR_REGISTRY/$ECR_REPOSITORY:${VERSION_TAG}
docker build --platform linux/amd64 --push -t ${TAG} -f ${{ env.Dockerfile_Backend }} .
- name: Build Backend image
if: github.event_name == 'pull_request'
run: |
docker build --platform linux/amd64 -f ${{ env.Dockerfile_Backend }} .
- name: Build Web and and push
if: github.event_name != 'pull_request'
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.WEB_ECR_REPOSITORY }}
run: |
VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3)
TAG=$ECR_REGISTRY/$ECR_REPOSITORY:${VERSION_TAG}
docker build --platform linux/amd64 --push -t ${TAG} -f ${{ env.Dockerfile_Web }} web/
- name: Build Web image
if: github.event_name == 'pull_request'
run: |
docker build --platform linux/amd64 -f ${{ env.Dockerfile_Web }} web/