Added secrets in GitHub Environment #6
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: Build and Deploy Code | |
# when does CI/CD trigger (on) | |
# it triggers (on) when git push/pull_request is main on specified branches | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
branches: | |
- "main" | |
# A job is a set of steps in a workflow that is executed on the same runner. | |
# Each step is either a shell script that will be executed, or an action that will be run. | |
# Steps are executed in order and are dependent on each other. | |
# Since each step is executed on the same runner, you can share data from one step to another. | |
jobs: | |
job1: | |
environment: # fetch variable from github environment | |
name: testing | |
env: | |
# Database Environment Variables | |
DATABASE_HOSTNAME: ${{secrets.DATABASE_HOSTNAME}} # fetches values from Github Action Secrets / Environment | |
DB_PASSWORD: ${{secrets.DB_PASSWORD}} | |
DATABASE_PORT: ${{secrets.DATABASE_PORT}} | |
DATABASE_NAME: ${{secrets.DATABASE_NAME}} | |
DB_USERNAME: ${{secrets.DB_USERNAME}} | |
# Authorization Environment Variables | |
SECRET_KEY: ${{secrets.SECRET_KEY}} | |
ALGORITHM: ${{secrets.ALGORITHM}} | |
ACCESS_TOKEN_EXPIRE_MINUTES: ${{secrets.ACCESS_TOKEN_EXPIRE_MINUTES}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: pulling git repo | |
uses: actions/checkout@v4 | |
- name: install python version 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: upgrade pip | |
run: python -m pip install --upgrade pip | |
- name: install all dependencies | |
run: pip install -r requirements.txt | |
- name: test with pytest | |
run: | | |
pip install pytest | |
pytest |