0
0
Fork 1
Spiegel von https://github.com/A6-9V/MQL5-Google-Onedrive.git synchronisiert 2026-04-11 05:50:56 +00:00
MQL5-Google-Onedrive/.github/workflows/ci-cd-docker-dev.yml
google-labs-jules[bot] 96b2be8df2 fix(ci): Use correct Docker tag from metadata action output
Corrects the CI workflow to prevent 'manifest unknown' errors.

The `docker/metadata-action` generates a Docker tag with a shortened git SHA, but subsequent `docker run` and `docker pull` commands were attempting to use the full-length SHA, causing the image to not be found.

This fix modifies the `build-and-test` job to expose the generated tags as an output. The test and deployment steps are updated to consume this output, ensuring that the correct, shortened SHA tag is used throughout the workflow.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-29 17:37:28 +00:00

157 Zeilen
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: ubuntu-latest
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: ubuntu-latest
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: ubuntu-latest
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