Skip to content

Commit

Permalink
backend workflow added
Browse files Browse the repository at this point in the history
  • Loading branch information
Amarjha01 committed Aug 30, 2024
1 parent ce94a1d commit 8e633be
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy Backend to Docker Hub and Elastic Beanstalk

on:
push:
branches:
- main
- backend

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.11.1'

- name: Build Docker image
run: |
docker build -t my-backend-app -f Dockerfile .
- name: Log in to Docker Hub
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
run: |
echo "$DOCKER_HUB_ACCESS_TOKEN" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
- name: Tag Docker image
run: |
docker tag my-backend-app:latest amarjha01/electramart:latest
- name: Push Docker image to Docker Hub
run: |
docker push amarjha01/electramart:latest
- name: Install AWS Elastic Beanstalk CLI
run: |
sudo pip install awsebcli
- name: Prepare source bundle for Elastic Beanstalk
run: |
mkdir -p eb-deploy
cp Dockerfile eb-deploy/Dockerfile
cp -r backend/* eb-deploy/
cd eb-deploy
zip -r ../app.zip .
- name: Deploy to Elastic Beanstalk
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ap-south-1
run: |
eb init -p docker my-backend-app --region $AWS_REGION
eb use my-backend-app-env
eb deploy

0 comments on commit 8e633be

Please sign in to comment.