Update README.md #4
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: Python Application CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- cicd_github_actions | |
pull_request: | |
branches: | |
- cicd_github_actions | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest pytest-mock | |
if [ -d "server/" ]; then | |
pip install -r server/requirements.txt | |
fi | |
if [ -d "client/" ]; then | |
pip install -r client/requirements.txt | |
fi | |
- name: Run tests in Server | |
run: | | |
cd server | |
pytest | |
- name: Run tests in Client | |
run: | | |
cd client | |
pytest | |
- name: Build Docker Image for Server | |
run: | | |
if [ -d "server/" ]; then | |
cd server | |
docker build -t fastapi-server . | |
fi | |
- name: Run Docker Container | |
if: ${{ github.workspace }}/server | |
run: | | |
docker run -d -p 8000:8000 fastapi-server | |
- name: Docker login | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker image to registry | |
run: | | |
docker tag fastapi-server $DOCKER_REGISTRY_URL/fastapi-server:latest | |
docker push abhimazu/fastapi-server:latest |