amend security test settings.py #63
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: Django CI/CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
PYTHON_VERSION: '3.11.0' | |
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }} | |
SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
jobs: | |
test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Cache Python packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install flake8 pytest pytest-django coverage | |
- name: Run Linting | |
run: | | |
flake8 . --count --max-line-length=120 --statistics | |
- name: Run Tests with Coverage | |
env: | |
DJANGO_SETTINGS_MODULE: app.settings | |
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }} | |
run: | | |
coverage run -m pytest | |
coverage report | |
- name: Upload Coverage Reports | |
uses: codecov/codecov-action@v3 | |
deploy: | |
needs: test | |
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request_target' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Deploy to Render | |
env: | |
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }} | |
RENDER_DEPLOY_HOOK: ${{ secrets.RENDER_DEPLOY_HOOK }} | |
run: | | |
curl -X POST $RENDER_DEPLOY_HOOK \ | |
-H "Authorization: Bearer $RENDER_API_KEY" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"serviceId": "${{ secrets.RENDER_SERVICE_ID }}", | |
"clearCache": "true" | |
}' |