Skip to content

Git Workflow

Version: Arctyk ITSM v0.6.0+
Last Updated: January 2026

Git branching strategy and workflow for Arctyk ITSM.


Branches

  • main - Production-ready code
  • feature/* - New features
  • fix/* - Bug fixes

Workflow

  1. Create branch from main
  2. Make changes
  3. Push branch
  4. Open pull request
  5. Code review
  6. Merge to main

Git Push & Deploy Workflow Guide

Overview

Your project uses GitHub Actions to automatically test and deploy when you push to the main branch.

Branch Structure

  • main: Production branch - triggers tests + deployment to Droplet
  • dev: Development branch - triggers tests only
  • Feature branches: For development work

Step-by-Step: Push to Production

1. Make Your Changes

# Edit files as needed
# Save your work

2. Check Status

git status
# Shows: modified files, staged files, current branch

3. Stage Your Changes

# Stage specific files
git add src/users/templates/users/partials/user_history.html
git add src/tickets/templates/tickets/partials/ticket_history.html

# OR stage everything
git add .

4. Commit Your Changes

git commit -m "fix: add null check for changed_by in history templates"
# Use conventional commits: feat:, fix:, chore:, docs:, refactor:, test:

5. Push to GitHub

git push origin main
# This triggers GitHub Actions workflow

6. Monitor Deployment

Go to: https://github.com/your-username/arctyk-itsm/actions Watch the CI/CD Pipeline run:

  • Test job: Runs pytest suite (~60 seconds)
  • Build-and-deploy job: Builds Docker image, pushes to DockerHub, deploys to Droplet (~3-5 minutes)

What Happens on Push to Main

  1. GitHub Actions Triggers (ci-cd.yml)

  2. Runs on: push to main branch only

  3. Test Job (Always runs)

  4. Spins up PostgreSQL 17 + Redis 7

  5. Installs Python 3.13 + dependencies
  6. Runs migrations
  7. Runs pytest with coverage
  8. Uploads coverage to Codecov

  9. Build-and-Deploy Job (Only if tests pass)

  10. Extracts version from pyproject.toml

  11. Builds Docker image
  12. Pushes to DockerHub as:
    • username/arctyk:latest
    • username/arctyk:0.6.0 (version tag)
  13. SSH to your Droplet at $DROPLET_HOST
  14. Runs on server:

    cd /srv/arctyk-itsm
    git pull origin main
    docker compose pull
     docker compose up -d
     # If templates/static look stale, restart web service
     docker compose restart web
    docker system prune -f
    

  15. Your App Restarts with new code

Common Issues & Fixes

Issue: "Push doesn't trigger deployment"

Cause: Branch tracking wrong remote Fix:

git branch --set-upstream-to=origin/main main

Issue: "Changes not showing on server"

Cause: Multiple possible reasons Debug:

# 1. Check if push succeeded
git status  # Should say "up to date with origin/main"

# 2. Check GitHub Actions
# Visit: https://github.com/your-username/arctyk-itsm/actions
# Look for green checkmark or red X

# 3. SSH to server and check
ssh -i ~/.ssh/github-actions-arctyk root@YOUR_DROPLET_IP
cd /srv/arctyk-itsm
git log -1  # Check latest commit
docker compose logs web  # Check container logs

# Refresh containers if code is behind or web didn't restart
git pull origin main
docker compose pull
docker compose up -d
docker compose restart web

Issue: "Tests fail on GitHub but pass locally"

Common causes:

  • Database state differences (migrations)
  • Missing environment variables
  • Test uses hardcoded paths
  • Race conditions in async tests

Fix: Run tests exactly as GitHub does:

$env:PYTHONPATH = "src"
$env:DATABASE_URL = "postgres://arctyk:arctyk@localhost:5432/arctyk_test"
pytest --maxfail=1 --disable-warnings

Issue: "Forgot to commit some files"

# Stage the missing files
git add path/to/forgotten/file.py

# Amend the last commit (if not pushed yet)
git commit --amend --no-edit

# Force push (only if not shared with others)
git push origin main --force

# OR make a new commit (safer)
git commit -m "fix: add missing file"
git push origin main

Quick Reference

Verify Branch Tracking

git branch -vv
# Should show: * main [origin/main] ...

Check Remote Branches

git remote -v
git branch -r  # List remote branches

Pull Latest from Main

git pull origin main

View Recent Commits

git log --oneline -10

Check What Changed

git diff  # Unstaged changes
git diff --staged  # Staged changes
git diff origin/main  # Compare with remote

Workflow Best Practices

  1. Always check status before committing
git status
  1. Pull before you push (if working with team)
git pull origin main
git push origin main
  1. Use meaningful commit messages

  2. feat: add user history timeline

  3. fix: resolve null reference in changelog
  4. chore: update dependencies

  5. Check GitHub Actions after every push

  6. Ensure tests pass

  7. Confirm deployment succeeds
  8. Check server logs if issues arise

  9. Test locally before pushing

    pytest
    

Emergency Rollback

If deployment breaks production:

Option 1: Revert Last Commit

git revert HEAD
git push origin main
# Triggers new deployment with changes reverted

Option 2: Rollback on Server

ssh -i ~/.ssh/github-actions-arctyk root@YOUR_DROPLET_IP
cd /srv/arctyk-itsm
git log --oneline -5  # Find good commit
git checkout abc1234  # Replace with good commit hash
docker compose up -d --build

Option 3: Use Previous Docker Tag

ssh -i ~/.ssh/github-actions-arctyk root@YOUR_DROPLET_IP
cd /srv/arctyk-itsm
# Edit docker-compose.yml to use specific version tag
# Change: image: username/arctyk:latest
# To: image: username/arctyk:0.5.0
docker compose up -d

Monitoring Deployment

Check GitHub Actions Status

# Use GitHub CLI (if installed)
gh run list --limit 5

# Or visit in browser
start https://github.com/your-username/arctyk-itsm/actions

Check Server Status

ssh -i ~/.ssh/github-actions-arctyk root@YOUR_DROPLET_IP "cd /srv/arctyk-itsm && docker compose ps"

View Live Logs

ssh -i ~/.ssh/github-actions-arctyk root@YOUR_DROPLET_IP
cd /srv/arctyk-itsm
docker compose logs -f web
# Ctrl+C to exit

Next Steps

Now that tracking is fixed, your workflow is:

  1. Make changes locally
  2. git add . (or specific files)
  3. git commit -m "type: message"
  4. git push origin main
  5. Watch GitHub Actions at https://github.com/your-username/arctyk-itsm/actions
  6. Wait ~5 minutes for deployment
  7. Check your Droplet: Your changes are live!