Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action for Backend and Web app (ECR) #489

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build-push-ecr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Push
on:
push:
tags: [ 'v*' ]
pull_request:
branches: [ "main" ]

env:
Dockerfile-Backend: Dockerfile
Dockerfile-Web: web/Dockerfile
jobs:
build:
runs-on: ubuntu-latest
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.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
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 ${Dockerfile-Backend} .

- name: Build Backend image
if: github.event_name == 'pull_request'
run: |
docker build --platform linux/amd64 -f ${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 ${Dockerfile-Web} .

- name: Build Web image
if: github.event_name == 'pull_request'
run: |
docker build --platform linux/amd64 -f ${Dockerfile-Web} .






Loading