mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-03 01:47:23 -04:00
Docker tags require lowercase repository names. Convert github.repository_owner to lowercase before using in tags.
64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # Triggers on v1.0.0, v2.1.3, etc.
|
|
workflow_dispatch: # Manual trigger option
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract version from tag
|
|
id: meta
|
|
run: |
|
|
# Ensure we're building from a tag
|
|
if [[ "$GITHUB_REF" != refs/tags/* ]]; then
|
|
echo "Error: This workflow should only run on tag pushes"
|
|
echo "GITHUB_REF: $GITHUB_REF"
|
|
exit 1
|
|
fi
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Building version: $VERSION"
|
|
|
|
# Docker tags must be lowercase
|
|
REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
|
echo "repo_owner_lower=$REPO_OWNER_LOWER" >> $GITHUB_OUTPUT
|
|
echo "Repository owner (lowercase): $REPO_OWNER_LOWER"
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:${{ steps.meta.outputs.version }}
|
|
ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Image published
|
|
run: |
|
|
echo "✅ Docker image published successfully!"
|
|
echo "📦 Pull with: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:${{ steps.meta.outputs.version }}"
|
|
echo "📦 Or latest: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:latest"
|