Add .env variables to Github secrets #19
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 test web application | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run docker compose and wait until web server is up | |
env: | |
DB_HOST: ${{ secrets.DB_HOST }} | |
DB_NAME: ${{ secrets.DB_NAME }} | |
DB_USER: ${{ secrets.DB_USER }} | |
DB_PASS: ${{ secrets.DB_PASS }} | |
run: | | |
echo "DB_HOST=$DB_HOST" > .env | |
echo "DB_NAME=$DB_NAME" >> .env | |
echo "DB_USER=$DB_USER" >> .env | |
echo "DB_PASS=$DB_PASS" >> .env | |
docker-compose up --build -d | |
timeout 60 bash -c 'until echo > /dev/tcp/localhost/8000; do sleep 1; done' | |
- name: Run tests | |
run: pytest tests/api.py | |
- name: Stop and remove container | |
run: docker-compose down |