SOP: Dev to Prod Development - sdwilt-dtech/aussie2 GitHub Wiki

GitHub Actions SOP: Dev to Prod Deployment


GitHub Actions SOP: Dev to Prod Deployment

๐Ÿงช CI/CD Pipeline Summary

This repository uses GitHub Actions for automated testing, linting, and deployment for Linux-based applications.


Local Setup

bash
CopyEdit
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt pre-commit install

Run:

bash
CopyEdit
make check # or python cli.py check

Workflow File: .github/workflows/test.yml

Triggered on every push and pull_request:

  • Lints code with flake8

  • Checks formatting with black

  • Runs tests using pytest


Pull Request Process

  1. Create a feature branch:

    bash
    CopyEdit
    git checkout -b feature/xyz
  2. Run checks locally:

    bash
    CopyEdit
    make check
  3. Push and open a pull request.

  4. GitHub Actions auto-runs the CI checks.

  5. Only merge once:

    • โœ… All checks pass

    • โœ… Code is reviewed


Branch Protection Rules

  • Main branch is protected.

  • Rules:

    • โœ… Require status checks to pass

    • โœ… Require PR before merge

    • โœ… Optional: Require at least one reviewer


Deployment (Optional)

You can trigger a deployment workflow using GitHub Actions when pushing tags like v1.0.0.

Sample Workflow (deploy.yml)

yaml
CopyEdit
on: push: tags: - 'v*.*.*' jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: SSH Deploy run: ssh ${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }} << EOF cd /var/www/app git pull origin main sudo systemctl restart app.service EOF

Key Files

File | Purpose -- | -- .github/workflows/test.yml | CI workflow Makefile / cli.py | Developer shortcuts .flake8 | Lint config .pre-commit-config.yaml | Git hook setup deploy.yml | Deployment workflow (optional)
โš ๏ธ **GitHub.com Fallback** โš ๏ธ