create wsgi file for prod deployment #2
This file contains hidden or 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: REST-API-CI-Pipeline | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| paths: | |
| - 'app/**' | |
| pull_request: | |
| branches: | |
| - dev | |
| paths: | |
| - 'app/**' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run Tests with SQLite | |
| run: | | |
| pytest -v | |
| - name: Build Docker Image | |
| run: | | |
| IMAGE_TAG=${GITHUB_SHA::7} # short commit SHA | |
| echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV | |
| docker build -t flask-app:$IMAGE_TAG . | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Push Docker Image to Docker Hub | |
| run: | | |
| docker tag flask-app:$IMAGE_TAG ${{ secrets.DOCKER_HUB_USERNAME }}/flask-app:$IMAGE_TAG | |
| docker push ${{ secrets.DOCKER_HUB_USERNAME }}/flask-app:$IMAGE_TAG | |
| - name: Cleanup Local Docker Images | |
| run: | | |
| docker rmi flask-app:$IMAGE_TAG || true | |
| docker rmi ${{ secrets.DOCKER_HUB_USERNAME }}/flask-app:$IMAGE_TAG || true | |
| docker system prune -f || true |