Skip to content

Commit

Permalink
feat: Github Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarMWarraich committed Aug 3, 2024
1 parent 12f8ed1 commit 91b51fb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy

on:
push:
branches:
- main

jobs:
Production:
name: Deploy to Production
runs-on: ubuntu-latest
environment: Production
steps:
- uses: actions/checkout@v3
- name: Build & Deploy
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOST: ${{secrets.SSH_HOST}}
USER_NAME: ${{secrets.USER_NAME}}

run: |
echo "Deploying to EC2"
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${{ secrets.USER_NAME }}@${{ secrets.SSH_HOST }} '
cd /home/ubuntu/ && cd ror-react-app &&
git reset --hard &&
git checkout main &&
git pull origin main &&
docker-compose down &&
docker-compose rm -fsv &&
docker-compose up --build -d
'
6 changes: 3 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ test:
#
production:
<<: *default
database: ror_react_app_production
username: ror_react_app
password: <%= ENV["ROR_REACT_APP_DATABASE_PASSWORD"] %>
database: <%= ENV["POSTGRES_DB"] %>
username: <%= ENV["POSTGRES_USER"] %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3"
services:
db:
image: postgres:14.2-alpine
container_name: demo-postgres-14.2
volumes:
- postgres_data:/var/lib/postgresql/data
command: "postgres -c 'max_connections=500'"
env_file:
- .ror-env
ports:
- "5432:5432"
ror-react-app:
build: .
command: "./bin/rails server"
env_file:
- .ror-env
volumes:
- app-storage:/rails/storage
depends_on:
- db
ports:
- "3000:3000"

volumes:
postgres_data: {}
app-storage: {}

0 comments on commit 91b51fb

Please sign in to comment.