Skip to content

Commit

Permalink
Merge pull request #94 from hngprojects/devops-main
Browse files Browse the repository at this point in the history
  • Loading branch information
bolexs authored Jul 19, 2024
2 parents 88526e5 + 9782559 commit 2a01f66
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cd.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dev Branch Deployment

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [dev]

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use SSH Action
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd python/dev_source_code/
git pull origin dev
source .venv/bin/activate
pip install -r requirements.txt
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
36 changes: 36 additions & 0 deletions .github/workflows/cd.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dev Branch Deployment

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [main]

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use SSH Action
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd python/prod_source_code/
git pull origin main
source .venv/bin/activate
pip install -r requirements.txt
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
36 changes: 36 additions & 0 deletions .github/workflows/cd.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dev Branch Deployment

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [staging]

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use SSH Action
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd python/staging_source_code/
git pull origin staging
source .venv/bin/activate
pip install -r requirements.txt
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [main, staging, dev]
pull_request:
branches: [main, staging, dev]

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

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER:
POSTGRES_PASSWORD:
POSTGRES_DB:
ports:
- 5432:5432

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
virtual-environment: venv

- name: Install dependencies
run: |
pip install -r requirements.txt
# - name: Copy env file
# run: cp .env.sample .env

# - name: Copy env file for main
# if: github.ref == 'refs/heads/main'
# run: cp .env.production .env

# - name: Copy env file for staging
# if: github.ref == 'refs/heads/staging'
# run: cp .env.staging .env

# - name: Run migrations
# run: |
# activate
# alembic upgrade head

# - name: Run tests
# run: |
# activate
# pytest

0 comments on commit 2a01f66

Please sign in to comment.