Skip to content
Open
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
e84c0fb
feat(issue-1): Basic AI Plugin Project Architecture Implementation
KariHall619 Sep 15, 2025
74dec47
feat(issue-2): Implementation of the Standard Loader Interface Archit…
KariHall619 Sep 15, 2025
1d9eb41
Issue #5: Complete AI service abstraction layer implementation
KariHall619 Sep 15, 2025
a4c18fe
feat(Issue-7): Complete configuration management system implementation
KariHall619 Sep 15, 2025
27d0746
feat(Issue-3): Implement comprehensive SQL generation with AI integra…
KariHall619 Sep 15, 2025
a0b72d5
Issue #4: Implement ai.capabilities method with comprehensive capabil…
KariHall619 Sep 15, 2025
32a0b94
Issue #6: Enhance AI service integrations with production-ready features
KariHall619 Sep 15, 2025
131425b
feat(issue-8): Implement CI/CD infrastructure for the integrated test…
KariHall619 Sep 16, 2025
677c400
feat(issue-9): 完成部署和文档完善 - 生产就绪
KariHall619 Sep 16, 2025
8b2dcd4
fix: Update copyright dates from 2023-2025 to 2025 for newly created …
KariHall619 Sep 19, 2025
991b5d7
fix: Resolve compilation issues with Duration type usage
KariHall619 Sep 19, 2025
44aa4a4
chore: Remove unnecessary files and improve .gitignore
KariHall619 Sep 19, 2025
d93a222
fix: 将项目名称从atest-store-ai更改为atest-ext-ai
KariHall619 Sep 20, 2025
eeadb6a
fix: 添加feature分支的CI触发支持
KariHall619 Sep 20, 2025
d9c31cc
fix: 修复CI流水线中的gosec action问题
KariHall619 Sep 20, 2025
120bba8
fix: 修复gosec SARIF文件生成问题
KariHall619 Sep 20, 2025
23d0d50
fix: 简化gosec安全扫描配置
KariHall619 Sep 20, 2025
de71773
fix: 修复代码格式问题
KariHall619 Sep 20, 2025
d14cd51
fix: 修复golangci-lint代码质量问题
KariHall619 Sep 20, 2025
b5a8cdf
fix: 修复circuit.go格式问题
KariHall619 Sep 20, 2025
495c834
fix: resolve critical test failures and config parsing issues
KariHall619 Sep 20, 2025
5a03871
fix: code formatting and dependency organization
KariHall619 Sep 20, 2025
e10e689
fix: resolve all golangci-lint issues and CI failures
KariHall619 Sep 20, 2025
17ce7a4
fix: correct gosec installation path in CI workflow
KariHall619 Sep 20, 2025
bd37fc7
fix: resolve critical test failures for CI
KariHall619 Sep 20, 2025
4592f91
refactor: clean up configuration loader and optimize code structure
KariHall619 Sep 20, 2025
59263e1
fix: resolve test execution issues and Duration type handling
KariHall619 Sep 20, 2025
16c4a69
feat: add integration test suite for CI/CD
KariHall619 Sep 20, 2025
6f29c65
fix: resolve Docker build failures in CI/CD pipeline
KariHall619 Sep 20, 2025
7f79ca3
fix: remove invalid Docker SHA tag format from CI workflow
KariHall619 Sep 20, 2025
63921da
fix: update Go version to 1.24 to match go.mod requirements
KariHall619 Sep 20, 2025
780625c
fix: add missing cmd/atest-ext-ai/main.go to resolve Docker build fai…
KariHall619 Sep 20, 2025
92d0a39
fix: update to Docker Compose V2 commands in CI workflow
KariHall619 Sep 20, 2025
c4e2588
fix: resolve PostgreSQL port conflicts in Docker Compose
KariHall619 Sep 20, 2025
90b856d
fix: resolve Redis port conflicts and Trivy image scanning issues
KariHall619 Sep 20, 2025
d5f34e4
fix: resolve Trivy image tag parsing errors with invalid characters
KariHall619 Sep 20, 2025
a70a47b
fix: implement optimal solution for persistent port conflicts
KariHall619 Sep 20, 2025
e88c8e9
fix: resolve Ollama container healthcheck failures
KariHall619 Sep 20, 2025
c7a3a56
fix: implement comprehensive Docker tag sanitization
KariHall619 Sep 20, 2025
b8ea5bd
fix: add comprehensive debugging and improve Ollama healthcheck relia…
KariHall619 Sep 20, 2025
7462652
fix: implement comprehensive CI reliability improvements
KariHall619 Sep 20, 2025
4940c16
fix: resolve Docker health dependency chain and Trivy scanning failures
KariHall619 Sep 20, 2025
d8369fe
fix: resolve atest-ai-plugin-dev service startup and configuration is…
KariHall619 Sep 20, 2025
5f82205
fix: implement comprehensive memory optimization to prevent OOM kills
KariHall619 Sep 20, 2025
55b4691
docs: add project simplification plan
KariHall619 Sep 22, 2025
f27f028
refactor: major project simplification - remove non-core complexity
KariHall619 Sep 22, 2025
2f42708
Revert "docs: add project simplification plan"
KariHall619 Sep 22, 2025
95b0b11
fix: add missing CI targets to Makefile
KariHall619 Sep 22, 2025
054f0a1
security: fix gosec security issues and CI configuration
KariHall619 Sep 22, 2025
9e26f1d
refactor: replace manual build process with GoReleaser
KariHall619 Sep 22, 2025
7da4e13
ci: Remove outdated deployment workflows and configurations
KariHall619 Sep 22, 2025
786896d
feat: implement AI interface standard compliance in plugin service
KariHall619 Sep 22, 2025
cd427b2
feat: add main project integration tests for AI plugin
KariHall619 Sep 22, 2025
e0f8c51
refactor: simplify AI plugin architecture for better maintainability
KariHall619 Sep 23, 2025
eed75df
refactor: remove enterprise patterns and simplify codebase
KariHall619 Sep 23, 2025
0e29503
fix: update Makefile targets for removed components
KariHall619 Sep 23, 2025
f3ed5da
fix: format code according to Go standards
KariHall619 Sep 23, 2025
6b43f95
fix: resolve CI pipeline issues after architecture simplification
KariHall619 Sep 23, 2025
8d8b72c
fix: resolve CI/CD pipeline issues and improve code quality
KariHall619 Sep 23, 2025
c0bd077
fix: resolve Trivy security scan image name parsing error
KariHall619 Sep 23, 2025
4e0c058
fix: JavaScript syntax error in AI chat interface
KariHall619 Sep 23, 2025
d6e362a
security: remove hardcoded database password and fix dual main.go issue
KariHall619 Sep 24, 2025
4fd8ef0
refactor: separate frontend assets from Go code using embed
KariHall619 Sep 24, 2025
f509749
fix: accept empty type field in Query method for backward compatibility
KariHall619 Sep 24, 2025
1b80ab5
feat: implement universal AI API adapter and Ollama auto-discovery
KariHall619 Sep 25, 2025
ec6bf40
UI fix: move AI settings button from header to input area
KariHall619 Sep 25, 2025
7fab945
fix: resolve JavaScript syntax error and improve AI plugin functionality
KariHall619 Sep 25, 2025
d4b1b04
feat: enhance AI plugin UI and functionality
KariHall619 Sep 25, 2025
aa9b5cb
fix: make database type configurable instead of hardcoded
KariHall619 Sep 25, 2025
099c180
chore: clean up temporary test files and development artifacts
KariHall619 Sep 25, 2025
c350b0f
chore: update gitignore to exclude temporary test files
KariHall619 Sep 25, 2025
b7a640c
security: fix critical security vulnerabilities in production setup
KariHall619 Sep 26, 2025
812ebac
feat: implement automatic AI model detection for local providers
KariHall619 Sep 26, 2025
98b62a3
config: standardize environment variable naming with ATEST_EXT_AI prefix
KariHall619 Sep 26, 2025
4ab2409
fix: provide default Ollama endpoint instead of requiring environment…
KariHall619 Sep 27, 2025
a3cf594
fix: resolve provider name mapping issue in UI model discovery
KariHall619 Sep 27, 2025
675c58d
fix: increase HTTP client timeout to resolve AI generation timeout issue
KariHall619 Sep 27, 2025
c5d2d6c
refactor: Simplify project structure and remove Docker-related files
KariHall619 Sep 28, 2025
79b20cd
Removes ollama demo
KariHall619 Sep 28, 2025
4aabf49
test(discovery): 移动Ollama发现测试文件到pkg目录并删除旧测试文件
KariHall619 Sep 28, 2025
b5c7b38
refactor: 简化构建和部署流程
KariHall619 Sep 29, 2025
334fe50
Enhances AI engine with provider support
KariHall619 Sep 29, 2025
b04d166
Simplifies AI response format for SQL generation
KariHall619 Sep 29, 2025
c1564cb
Initialize frontend project with build configurations
KariHall619 Oct 5, 2025
782da38
Add TypeScript type definitions with AppContext
KariHall619 Oct 5, 2025
fdb37d7
Implement useAIChat composable with context integration
KariHall619 Oct 5, 2025
e77ff59
Implement Vue components with context injection
KariHall619 Oct 5, 2025
6eae926
Implement plugin entry point with context support
KariHall619 Oct 5, 2025
70b4554
Fix TypeScript compilation errors and build
KariHall619 Oct 5, 2025
0a138c4
Fix: Remove language settings from plugin config
KariHall619 Oct 5, 2025
fa64aa9
Fix critical API call bug and improve translations
KariHall619 Oct 5, 2025
25933ca
Add comprehensive test suite and refactor code
KariHall619 Oct 5, 2025
8a8869a
Refactor: Extract API calls to service layer
KariHall619 Oct 5, 2025
42b87fe
Update: Sync aiService refactored frontend to backend assets
KariHall619 Oct 6, 2025
df9b72b
Refactor: Configure Vite to output directly to assets directory
KariHall619 Oct 6, 2025
1a50753
Fix socket path to match main server expectation
KariHall619 Oct 6, 2025
cd4eaee
Decouple health check from AI service availability
KariHall619 Oct 6, 2025
dc5d54b
Fix plugin UI loading by switching to UMD format
KariHall619 Oct 6, 2025
118c10f
Fix browser compatibility by injecting process polyfill
KariHall619 Oct 6, 2025
64fca4d
Major UI/UX overhaul: Modern chat interface and organized settings
KariHall619 Oct 6, 2025
8471a1a
fix: separate model lists per provider to prevent cross-contamination
KariHall619 Oct 6, 2025
92520f3
feat: enhance connection test with detailed error messages
KariHall619 Oct 6, 2025
4a89b10
feat: update model lists to latest versions
KariHall619 Oct 6, 2025
3b74917
fix: handle both string and object types for meta field
KariHall619 Oct 6, 2025
be8f92b
fix: improve chat alignment, add empty state, and unify UI style
KariHall619 Oct 6, 2025
195ecf6
style: unify AISettingsPanel with Element Plus theme
KariHall619 Oct 6, 2025
5907a1a
style: unify AIChatInput with Element Plus theme
KariHall619 Oct 6, 2025
06030fc
style: unify AIChatHeader with Element Plus theme
KariHall619 Oct 6, 2025
ac1c4fb
Add comprehensive debug logging to diagnose local AI generation failures
KariHall619 Oct 6, 2025
f8e68fe
Refactor OpenAI client to use langchaingo library
KariHall619 Oct 10, 2025
694875a
Fix critical issues in OpenAI client implementation
KariHall619 Oct 10, 2025
306202b
Remove deprecated Temperature and TokenUsage features; cleanup unsupp…
KariHall619 Oct 10, 2025
c213f80
Clean up residual references to removed providers
KariHall619 Oct 10, 2025
fc24009
Refactor error handling to follow gRPC best practices
KariHall619 Oct 10, 2025
4053599
Replace debug print statements with structured logging
KariHall619 Oct 10, 2025
65e0df1
Add API versioning to plugin responses
KariHall619 Oct 10, 2025
33a32b6
Enhance config loader with version detection and migration warnings
KariHall619 Oct 10, 2025
fe54cca
Add comprehensive configuration migration guide
KariHall619 Oct 10, 2025
29656ff
Externalize hardcoded configuration values
KariHall619 Oct 10, 2025
bf87c75
Fix type conversion for retry multiplier
KariHall619 Oct 10, 2025
52bf32a
Remove over-engineered migration system and legacy config code
KariHall619 Oct 10, 2025
1da5076
feat: add modern development tooling
KariHall619 Oct 10, 2025
a533796
refactor: remove TOML support from config loader
KariHall619 Oct 10, 2025
4685b97
refactor: remove unused config structures
KariHall619 Oct 10, 2025
f314ef6
refactor: replace custom retry logic with cenkalti/backoff
KariHall619 Oct 10, 2025
c08f630
refactor: remove unused basicEngine implementation
KariHall619 Oct 10, 2025
689dd9d
style: apply code formatting standards
KariHall619 Oct 10, 2025
36edf0e
refactor(ai): simplify OllamaDiscovery to single responsibility
KariHall619 Oct 10, 2025
87ec39a
refactor(ai): implement strategy pattern for UniversalClient
KariHall619 Oct 10, 2025
0e8e32d
refactor(ai): merge local.Client into UniversalClient
KariHall619 Oct 10, 2025
1aa6769
fix(refactor): clean up remaining 'local' provider references
KariHall619 Oct 10, 2025
14cb1ed
Fix frontend-backend communication inconsistencies for 'local' provid…
KariHall619 Oct 10, 2025
e872853
docs(frontend): clarify 'local' provider alias usage in types
KariHall619 Oct 10, 2025
744b1f3
fix(engine): map 'local' to 'ollama' in runtime config parsing
KariHall619 Oct 10, 2025
78ed1fa
fix(config): add missing provider types to validation rules
KariHall619 Oct 10, 2025
b013271
fix(config): add missing defaults for ollama endpoint and model
KariHall619 Oct 10, 2025
cbb30e2
docs: add comprehensive quick start guide
KariHall619 Oct 10, 2025
143e475
docs: add comprehensive architecture refactoring documentation
KariHall619 Oct 10, 2025
095a63f
Refactor: Phase 1 - Merge ClientManager and ProviderManager into unif…
KariHall619 Oct 10, 2025
c66b7ff
Refactor: Phase 2 - Replace Viper with simple YAML configuration loader
KariHall619 Oct 10, 2025
1a131b5
Refactor: Phase 3 - Remove unnecessary interface abstractions
KariHall619 Oct 10, 2025
a434674
Refactor: Phase 5 - Code cleanup and optimization
KariHall619 Oct 10, 2025
1395438
Fix Dockerfile build flow and add config.yaml
KariHall619 Oct 10, 2025
df00a5e
Implement graceful degradation for plugin initialization
KariHall619 Oct 10, 2025
b8e7037
Relax configuration validation rules for better compatibility
KariHall619 Oct 10, 2025
2942733
Enhance socket permissions handling and diagnostics
KariHall619 Oct 10, 2025
e035da8
Add gRPC interface version checking and compatibility info
KariHall619 Oct 10, 2025
83f9f2d
Enhance error handling and diagnostic logging throughout
KariHall619 Oct 10, 2025
e6e2e49
Complete architecture simplification cleanup
KariHall619 Oct 10, 2025
fa1b6af
Fix critical runtime integration issues with api-testing main project
KariHall619 Oct 10, 2025
ef566aa
Fix critical field name mismatch: content -> generated_sql
KariHall619 Oct 10, 2025
97a75b7
Replace fmt.Printf with structured logging in generator
KariHall619 Oct 10, 2025
3f3c67a
Unify error field handling (Issue #2)
KariHall619 Oct 10, 2025
c97ebaa
Improve runtime client error handling (Issue #4)
KariHall619 Oct 10, 2025
c48a625
Optimize health check mechanism in AddClient (Issue #5)
KariHall619 Oct 10, 2025
b2d5922
Improve type assertion error handling (Issue #6)
KariHall619 Oct 10, 2025
59e78a2
feat(plugin): enhance error messages with initialization context
KariHall619 Oct 10, 2025
53fbfed
feat(universal): add HTTP connection pooling for improved performance
KariHall619 Oct 10, 2025
8879c55
feat: add Prometheus metrics for AI operations monitoring
KariHall619 Oct 10, 2025
9092a9f
refactor: simplify metrics to match BUGFIX_PLAN requirements
KariHall619 Oct 10, 2025
d03410b
Remove redundant comments to match BUGFIX_PLAN.md exactly
KariHall619 Oct 11, 2025
334e7d9
Fix error handling and resource cleanup issues
KariHall619 Oct 11, 2025
22377b2
Delete unused md
KariHall619 Oct 13, 2025
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
40 changes: 40 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Environment variables for atest-ext-ai plugin
# Copy this file to .env and customize for your environment

# =================
# AI CONFIGURATION
# =================

# AI Provider: local (Ollama), openai, claude
AI_PROVIDER=local

# Ollama Configuration (for local provider)
OLLAMA_ENDPOINT=http://localhost:11434

# AI Model (auto-detected if not set for local provider)
AI_MODEL=

# API Keys for cloud providers (leave empty for local)
AI_API_KEY=
OPENAI_API_KEY=
CLAUDE_API_KEY=

# =================
# PLUGIN SETTINGS
# =================

# Logging level: debug, info, warn, error
LOG_LEVEL=info

# Development mode flag
DEV_MODE=false

# =================
# ADVANCED SETTINGS
# =================

# Request timeout in seconds (optional)
REQUEST_TIMEOUT=30

# Maximum concurrent AI requests (optional)
MAX_CONCURRENT_REQUESTS=10
301 changes: 301 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
name: CI Pipeline

on:
push:
branches: [ main, master, develop, 'feature/**' ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master, develop ]

env:
GO_VERSION: 1.22
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
# Code quality and security checks
quality:
name: Code Quality & Security
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Clean Go module cache directory
run: |
rm -rf ~/.cache/go-build || true
rm -rf ~/go/pkg/mod || true

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Install dependencies
run: make deps

- name: Format check
run: |
make fmt
if [ -n "$(git status --porcelain)" ]; then
echo "Code is not formatted properly"
git diff
exit 1
fi

- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --timeout=10m

- name: Security check with gosec
run: |
# Install gosec
go install github.com/securego/gosec/v2/cmd/gosec@latest

# Run gosec (allow it to fail)
echo "Running gosec security scan..."
gosec ./... || true

echo "Gosec scan completed"

- name: Verify Go modules
run: make mod-verify

# Comprehensive testing
test:
name: Test Suite
runs-on: ubuntu-latest
needs: quality
strategy:
matrix:
go-version: [1.22]
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: ci_test_password_postgres
POSTGRES_USER: ci_test_user
POSTGRES_DB: ci_test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: ci_test_root_password_mysql
MYSQL_DATABASE: ci_test_db
MYSQL_USER: ci_test_user
MYSQL_PASSWORD: ci_test_password_mysql
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
ports:
- 3306:3306

redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

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

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Clean Go module cache directory
run: |
rm -rf ~/.cache/go-build || true
rm -rf ~/go/pkg/mod || true

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}

- name: Install dependencies
run: make deps

- name: Run unit tests
run: make test
env:
POSTGRES_URL: postgres://testuser:testpass@localhost:5432/testdb?sslmode=disable
MYSQL_URL: testuser:testpass@tcp(localhost:3306)/testdb
REDIS_URL: redis://localhost:6379

- name: Verify plugin functionality
run: |
echo "Testing plugin build and basic functionality..."
make build
echo "Plugin built successfully"

- name: Run benchmarks
run: make benchmark

- name: Upload coverage to Codecov
if: matrix.go-version == '1.22'
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella

# Docker image build and push
docker:
name: Docker Build & Push
runs-on: ubuntu-latest
needs: [quality, test]
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Docker tag
id: docker-tag
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
TAG="pr-${{ github.event.number }}"
else
TAG="${{ github.ref_name }}"
# Sanitize tag name
TAG=$(echo "$TAG" | sed 's/[^a-zA-Z0-9_.-]/-/g')
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Generated Docker tag: $TAG"

- name: Generate lowercase image name
id: image-name
run: |
IMAGE_NAME_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
echo "name=$IMAGE_NAME_LOWER" >> $GITHUB_OUTPUT
echo "Generated lowercase image name: $IMAGE_NAME_LOWER"

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.name }}
tags: |
type=raw,value=${{ steps.docker-tag.outputs.tag }}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ github.sha }}
BUILD_DATE=${{ github.event.head_commit.timestamp }}


# Security scanning
security:
name: Security Scan
runs-on: ubuntu-latest
needs: [docker]
if: github.event_name != 'pull_request' && needs.docker.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Generate Docker tag for scanning
id: scan-tag
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
TAG="pr-${{ github.event.number }}"
else
TAG="${{ github.ref_name }}"
# Sanitize tag name
TAG=$(echo "$TAG" | sed 's/[^a-zA-Z0-9_.-]/-/g')
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Generate lowercase image name for scanning
id: scan-image-name
run: |
IMAGE_NAME_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
IMAGE_REF="${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:${{ steps.scan-tag.outputs.tag }}"
echo "image_ref=$IMAGE_REF" >> $GITHUB_OUTPUT
echo "Scanning Docker image: $IMAGE_REF"

- name: Wait for image availability
run: |
IMAGE_REF="${{ steps.scan-image-name.outputs.image_ref }}"
echo "Checking if image exists: $IMAGE_REF"

# Try to pull the image to verify it exists
if docker manifest inspect "$IMAGE_REF" >/dev/null 2>&1; then
echo "✅ Image found: $IMAGE_REF"
echo "SCAN_IMAGE=true" >> $GITHUB_ENV
else
echo "⚠️ Image not found: $IMAGE_REF"
echo "SCAN_IMAGE=false" >> $GITHUB_ENV
echo "Skipping Trivy scan - image not available"
fi

- name: Run Trivy vulnerability scanner
if: env.SCAN_IMAGE == 'true'
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.scan-image-name.outputs.image_ref }}
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy scan results to GitHub Security tab
if: env.SCAN_IMAGE == 'true' && always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
Loading