Merge pull request #3 from LionelMv/pre-dev #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: testdb | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd="pg_isready -U postgres" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install Pipenv | |
run: | | |
python -m pip install --upgrade pip | |
pip install pipenv | |
- name: Install dependencies | |
run: | | |
pipenv install --dev | |
- name: Set up environment variables | |
run: | | |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> $GITHUB_ENV | |
echo "GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" >> $GITHUB_ENV | |
echo "GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}" >> $GITHUB_ENV | |
echo "SMS_USERNAME=${{ secrets.SMS_USERNAME }}" >> $GITHUB_ENV | |
echo "SMS_API_KEY=${{ secrets.SMS_API_KEY }}" >> $GITHUB_ENV | |
- name: Set up Database | |
run: | | |
pipenv run python manage.py migrate | |
- name: Run Tests with coverage | |
run: | | |
pipenv run coverage run manage.py test | |
pipenv run coverage html | |
pipenv run coverage report | |
- name: Upload Coverage Report | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: htmlcov/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Deploy to your environment | |
# This is a placeholder. Configure your deployment steps here. | |
run: echo "Deploying application..." | |