Files

122 lines
4.0 KiB
YAML

name: Build & Publish Prepackaged Containers (GHCR)
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
# ============================================================================
# 1. Unit Test @job-bot/jobbot-mcp & Verify Upstream Web Patch
# ============================================================================
test-mcp:
name: Test jobbot-mcp & Web Patch
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Setup Node.js 26
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "26"
cache: "npm"
cache-dependency-path: mcp/jobbot-mcp/package-lock.json
- name: Install MCP dependencies
working-directory: mcp/jobbot-mcp
run: npm ci
- name: Build MCP TypeScript
working-directory: mcp/jobbot-mcp
run: npm run build
- name: Run MCP Unit Tests
working-directory: mcp/jobbot-mcp
run: npm test
- name: Verify patch-origin.py against pinned suxrobGM/jobpilot commit
run: python3 docker/web/patch-origin.py --dry-run
# ============================================================================
# 2. Build & Push All 6 Prepackaged Images to GitHub Container Registry
# ============================================================================
build-and-push:
name: Build & Push (${{ matrix.image.name }})
needs: test-mcp
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
image:
- name: postgres
context: ./docker/postgres
dockerfile: ./docker/postgres/Dockerfile
- name: api
context: ./docker/api
dockerfile: ./docker/api/Dockerfile
- name: web
context: ./docker/web
dockerfile: ./docker/web/Dockerfile
- name: terminal
context: .
dockerfile: ./docker/terminal/Dockerfile
- name: nginx
context: ./docker/nginx
dockerfile: ./docker/nginx/Dockerfile
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Lowercase repository owner/name for GHCR
id: repo
run: |
echo "repo_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Log in to GitHub Container Registry (GHCR)
if: github.event_name != 'pull_request'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata (tags & labels)
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ${{ env.REGISTRY }}/${{ steps.repo.outputs.repo_lower }}/${{ matrix.image.name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-
type=semver,pattern={{version}}
- name: Build and push container image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: ${{ matrix.image.context }}
file: ${{ matrix.image.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.image.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.image.name }}