Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Dev

Dev #7

Workflow file for this run

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 }}