MQL5-Google-Onedrive/.github/workflows/ci-cd-docker-dev.yml
google-labs-jules[bot] fb5d048638 Bolt: Optimize EA performance and fix CI runner acquisition
MQL5 Optimizations:
- Consolidate trade counting and profit calculation into a single history scan in `UpdateDailyStatistics()`.
- Optimize `IsTradingAllowed()` with fast math for hour extraction, replacing expensive `TimeToStruct()`.
- Reduce terminal API calls in `CheckDailyLimits()` by caching account balance.
- Reuse `TimeCurrent()` value in `OnTick()` and pass to sub-functions.

CI Fixes:
- Transition all workflows from `ubuntu-latest` to `self-hosted` runners.
- This resolves the "Runner of type hosted not acquired" failure by utilizing the repository's configured self-hosted infrastructure.

Impact: Measurably faster execution in MT5 'hot paths' and restored CI/CD functionality.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 20:58:25 +00:00

157 行
4.7 KiB
YAML

name: CI/CD - Docker Dev Deployment
on:
push:
branches: [ main, develop ]
paths:
- 'Dockerfile.dev'
- 'docker-compose.dev.yml'
- 'scripts/**'
- '.github/workflows/ci-cd-docker-dev.yml'
pull_request:
branches: [ main, develop ]
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'dev'
type: choice
options:
- dev
- cloud
env:
REGISTRY: ghcr.io
IMAGE_NAME: a6-9v/mql5-google-onedrive
jobs:
build-and-test:
name: Build and Test Docker Dev Image
runs-on: self-hosted
permissions:
contents: read
packages: write
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=dev-
- name: Build Docker Dev image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.dev
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Run tests in container
run: |
# Use the first tag from the metadata output, which corresponds to the dev-SHA tag
docker run --rm $(echo "${{ steps.meta.outputs.tags }}" | head -n 1) \
python -c "import sys; print('Python:', sys.version); sys.exit(0)"
- name: Image digest
run: echo ${{ steps.meta.outputs.digest }}
deploy-dev:
name: Deploy Dev Environment
needs: build-and-test
runs-on: self-hosted
if: github.ref == 'refs/heads/develop' || github.event_name == 'workflow_dispatch'
environment:
name: dev
url: https://mql5-automation-dev.example.com
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull latest dev image
run: |
# Use the SHA-based tag from the build job's output
docker pull $(echo "${{ needs.build-and-test.outputs.tags }}" | head -n 1) || \
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:develop || \
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
- name: Deploy to Docker Desktop (Local)
if: runner.os == 'Windows'
run: |
echo "Deploying to Docker Desktop..."
docker-compose -f docker-compose.dev.yml up -d
docker ps
- name: Deploy notification
uses: 8398a7/action-slack@v3
if: always()
with:
status: ${{ job.status }}
text: 'Deployment to dev environment completed'
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
deploy-cloud:
name: Deploy to Cloud Platform
needs: build-and-test
runs-on: self-hosted
if: github.ref == 'refs/heads/main' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'cloud')
environment:
name: production
url: https://mql5-automation.fly.dev
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Fly.io
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy to Fly.io
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: Deploy to Render (if configured)
if: false # Enable when Render is configured
run: |
echo "Render deployment would happen here"
# Render auto-deploys from GitHub integration