. #117
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 CI | |
on: | |
push: | |
paths: | |
- "server/**" | |
branches: | |
- dev | |
pull_request: | |
paths: | |
- "server/**" | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./server | |
steps: | |
- name: Checkout the Git Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11.9 | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Configure Poetry | |
run: | | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
poetry config virtualenvs.create false | |
- name: Install dependencies with Poetry | |
run: | | |
poetry install | |
# - name: Run tests | |
# run: | | |
# poetry run pytest tests/ | |
- name: Run security checks with bandit | |
uses: mdegis/[email protected] | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
path: "." | |
level: high | |
confidence: high | |
exit_zero: true | |
- name: Start application | |
run: | | |
sudo apt update -y | |
sudo apt install ffmpeg -y | |
export FLASK_APP=app | |
export FLASK_ENV=production | |
poetry run gunicorn -b 0.0.0.0:8000 app:app & | |
echo $! > gunicorn.pid | |
sleep 5 # give Flask time to start | |
continue-on-error: true | |
- name: Check application is running | |
run: | | |
curl --max-time 10 localhost:8000 | |
continue-on-error: true | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
continue-on-error: true | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: your-dockerhub-username/your-repo-name:latest | |
continue-on-error: true | |
deploy: | |
runs-on: ubuntu-latest | |
needs: docker-build | |
steps: | |
- name: Login to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
continue-on-error: true | |
- name: Deploy to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 'your-app-name' | |
slot-name: 'production' | |
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
images: 'your-dockerhub-username/your-repo-name:latest' | |
continue-on-error: true |