Skip to content

Commit

Permalink
add workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
MehulKChaudhari committed Mar 1, 2024
1 parent 9900c91 commit 71a9455
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 150 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/deploy-to-ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to EC2

on:
push:
branches:
- docker-aws

jobs:
build-and-deploy:
runs-on: ubuntu-latest

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

- name: Set up AWS CLI
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: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
run: aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com

- name: Build Docker Image
run: |
docker build -t ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/skill-tree-backend:latest .
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/skill-tree-backend:latest
- name: Deploy to EC2
run: |
# Example command to SSH into your EC2 instance and deploy the Docker container
ssh -i path/to/your/private/key.pem ec2-user@your-ec2-instance-ip "docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/skill-tree-backend:latest && docker run -d -p 80:8080 ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/skill-tree-backend:latest"
46 changes: 0 additions & 46 deletions .github/workflows/deploy-to-ecs.yml

This file was deleted.

104 changes: 0 additions & 104 deletions skill-tree/ecs-task-definition.json

This file was deleted.

0 comments on commit 71a9455

Please sign in to comment.