From b145a152d49c26b09b13a6ded087a56604513821 Mon Sep 17 00:00:00 2001 From: davmano <111084241+davmano@users.noreply.github.com> Date: Wed, 7 May 2025 10:48:29 -0500 Subject: [PATCH] feat(ci): add GitHub Action CI/CD pipeline for Flask App --- .../.github/workflows/flask-deploy.yml | 32 +++++++++++++++++ github-actions-flask-deploy/README.md | 34 +++++++++++++++++++ github-actions-flask-deploy/app.py | 9 +++++ github-actions-flask-deploy/requirements.txt | 1 + 4 files changed, 76 insertions(+) create mode 100644 github-actions-flask-deploy/.github/workflows/flask-deploy.yml create mode 100644 github-actions-flask-deploy/README.md create mode 100644 github-actions-flask-deploy/app.py create mode 100644 github-actions-flask-deploy/requirements.txt diff --git a/github-actions-flask-deploy/.github/workflows/flask-deploy.yml b/github-actions-flask-deploy/.github/workflows/flask-deploy.yml new file mode 100644 index 0000000..08d51a1 --- /dev/null +++ b/github-actions-flask-deploy/.github/workflows/flask-deploy.yml @@ -0,0 +1,32 @@ +name: Flask CI/CD + +on: + push: + branches: [ main ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests (placeholder) + run: | + echo "No tests defined." + + - name: Deploy (placeholder) + run: | + echo "App would deploy here (e.g., to Heroku, Render, EC2, etc)" + diff --git a/github-actions-flask-deploy/README.md b/github-actions-flask-deploy/README.md new file mode 100644 index 0000000..24df316 --- /dev/null +++ b/github-actions-flask-deploy/README.md @@ -0,0 +1,34 @@ +# GitHub Actions CI/CD Example – Flask App + +This example shows how to automate testing and deployment of a simple Flask application using GitHub Actions. + +## 📁 Structure + +- `app.py`: Basic Flask web app +- `requirements.txt`: Dependencies +- `.github/workflows/flask-deploy.yml`: CI/CD pipeline + +## 🚀 GitHub Actions Workflow + +Triggered on every push to `main`: + +1. Checkout code +2. Set up Python +3. Install dependencies +4. (Placeholder) Run tests +5. (Placeholder) Deploy app + +## 🔧 Deployment + +This example includes a placeholder deploy step. You can customize it to: + +- Deploy to EC2 via SSH +- Push to Heroku +- Use Docker + AWS ECS + +## ✅ Getting Started Locally + +```bash +pip install -r requirements.txt +python app.py + diff --git a/github-actions-flask-deploy/app.py b/github-actions-flask-deploy/app.py new file mode 100644 index 0000000..90e44f7 --- /dev/null +++ b/github-actions-flask-deploy/app.py @@ -0,0 +1,9 @@ +from flask import Flask + +app = Flask(__name__) + +@app.route('/') +def index(): + return "Hello From Github Actions CI/CD Pipeline!" + + diff --git a/github-actions-flask-deploy/requirements.txt b/github-actions-flask-deploy/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/github-actions-flask-deploy/requirements.txt @@ -0,0 +1 @@ +flask