Last active
November 30, 2022 20:53
-
-
Save peeush-agarwal/8a7c2bf5f6f3be07cf76d556cc2b2d7b to your computer and use it in GitHub Desktop.
GitHub Action workflow for CI/CD pipeline with Flask application
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
# This is a basic workflow to help you get started with Actions | |
name: Deploy to Raspberry Pi | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
FLASK_APP: app.py | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: self-hosted | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
# Setup virtual env, install dependencies | |
- name: Create new virtual env and activate it | |
run: | | |
python3 -m venv flask-env | |
source flask-env/bin/activate | |
python3 -m pip install -r requirements.txt | |
python3 -m pip install gunicorn | |
deploy: | |
runs-on: self-hosted | |
needs: build | |
steps: | |
# Kill gunicorn server, if running already | |
- name: Kill gunicorn | |
run: pkill gunicorn || true | |
# Run gunicorn server | |
- name: Run gunicorn | |
run: | | |
source flask-env/bin/activate | |
RUNNER_TRACKING_ID="" | |
gunicorn -w 1 -b 0.0.0.0:4000 app:app -D --log-file=gunicorn.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment