Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
venv/
.venv/
env/
ENV/
env.bak/
venv.bak/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Testing
.pytest_cache/
.coverage
.hypothesis/
htmlcov/
.tox/
.nox/

# Environment files
.env
.envrc
.env.*

# Git
.git/
.gitignore
.gitattributes

# Documentation
*.md
README.md
LICENSE
docs/

# CI/CD
.github/

# Development files
test_*.py
*_test.py
tests/

# OS
.DS_Store
Thumbs.db

# Logs
*.log

# Temporary files
tmp/
temp/
*.tmp
100 changes: 100 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build and Package Agent Bot Service

on:
push:
branches:
- 'main'
- 'devOps'
- 'dev'
pull_request:
branches:
- 'main'
- 'devOps'
- 'dev'

# Permissions needed to push Docker images to your org's GitHub packages
permissions:
contents: read
packages: write

jobs:
# JOB 1: Test the Python application
build-test:
name: Install Dependencies and Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint with flake8 (optional)
run: |
pip install flake8
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true

- name: Test import of main module
run: |
python -c "import main; print('Main module loaded successfully')"

# JOB 2: Build and push Docker image
build-and-push-docker:
name: Build & Push Docker Image
# This job only runs on pushes to 'main', 'devOps', or 'dev', not on PRs
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/devOps' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
# This job runs *after* the build-test job succeeds
needs: build-test

steps:
- name: Checkout code
uses: actions/checkout@v4

# This action generates smart tags for your Docker image
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }} # e.g., ghcr.io/TechTorque-2025/Agent_Bot
tags: |
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}

# Logs you into the GitHub Container Registry (GHCR)
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # This token is auto-generated

# Builds the Docker image and pushes it to GHCR
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: . # Dockerfile is in the root of this repo
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy Agent Bot Service to Kubernetes

on:
workflow_run:
# This MUST match the 'name:' of your build.yaml file
workflows: ["Build and Package Agent Bot Service"]
types:
- completed
branches:
- 'main'
- 'devOps'

jobs:
deploy:
name: Deploy Agent Bot Service to Kubernetes
# We only deploy if the build job was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
# We only need the SHA of the new image
- name: Get Commit SHA
id: get_sha
run: |
echo "sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT

# 1. Checkout your 'k8s-config' repository
- name: Checkout K8s Config Repo
uses: actions/checkout@v4
with:
# This points to your k8s config repo
repository: 'TechTorque-2025/k8s-config'
# This uses the org-level secret you created
token: ${{ secrets.REPO_ACCESS_TOKEN }}
# We'll put the code in a directory named 'config-repo'
path: 'config-repo'
# Explicitly checkout the 'main' branch
ref: 'main'

- name: Install kubectl
uses: azure/setup-kubectl@v3

- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq

- name: Set Kubernetes context
uses: azure/k8s-set-context@v4
with:
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} # This uses your Org-level secret

# 2. Update the image tag for the agent-bot service
- name: Update image tag in YAML
run: |
yq -i '(select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "ghcr.io/techtorque-2025/agent_bot:${{ steps.get_sha.outputs.sha }}"' config-repo/k8s/services/agent-bot-deployment.yaml

# Display file contents before apply for debugging
- name: Display file contents before apply
run: |
echo "--- Displaying k8s/services/agent-bot-deployment.yaml ---"
cat config-repo/k8s/services/agent-bot-deployment.yaml
echo "------------------------------------------------------"

# 3. Deploy the updated file
- name: Deploy to Kubernetes
run: |
kubectl apply -f config-repo/k8s/services/agent-bot-deployment.yaml
kubectl rollout status deployment/agent-bot-deployment
Loading
Loading