mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-10 20:40:56 +00:00
4.9 KiB
4.9 KiB
GitHub CI/CD Setup for Docker Dev Deployment
This guide explains how to set up GitHub Actions for automated Docker development deployment.
Prerequisites
- GitHub Account: Your GitHub account
- Docker Desktop installed and running
- GitHub Repository with Actions enabled
Step 1: Configure GitHub Secrets
Go to your repository → Settings → Secrets and variables → Actions
Required Secrets
Add the following secrets:
1. GitHub Token (Auto-generated)
- Name:
GITHUB_TOKEN - Value: Automatically provided by GitHub Actions
- Note: No action needed, already available
2. Docker Hub Credentials (Optional)
If deploying to Docker Hub:
- Name:
DOCKER_USERNAME - Value: Your Docker Hub username
- Name:
DOCKER_PASSWORD - Value: Your Docker Hub password/token
3. Fly.io Token (For cloud deployment)
- Name:
FLY_API_TOKEN - Value: Get from
flyctl auth tokenor Fly.io dashboard
4. Email Credentials (For notifications)
- Name:
GITHUB_EMAIL - Value: your-email@example.com
- Name:
GITHUB_PASSWORD - Value: [YOUR_PASSWORD]
- Note: ⚠️ SECURITY WARNING - Use GitHub Personal Access Token instead of password!
Recommended: Use Personal Access Token
Instead of using your password, create a GitHub Personal Access Token:
- Go to: https://github.com/settings/tokens
- Click Generate new token (classic)
- Select scopes:
repo(Full control of private repositories)workflow(Update GitHub Action workflows)write:packages(Upload packages to GitHub Container Registry)
- Copy the token
- Add as secret:
- Name:
GH_PAT - Value: Your personal access token
- Name:
Step 2: Enable GitHub Actions
- Go to repository → Settings → Actions → General
- Enable:
- ✅ Allow all actions and reusable workflows
- ✅ Allow actions to create and approve pull requests
- Save changes
Step 3: Configure Self-Hosted Runner (For Docker Desktop)
If you want to deploy to your local Docker Desktop:
Option A: Use GitHub-hosted Runner (Recommended)
The workflow will build the image, but deployment to Docker Desktop requires a self-hosted runner.
Option B: Set Up Self-Hosted Runner
-
Download runner:
# Create folder mkdir actions-runner cd actions-runner # Download (Windows) Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-win-x64-2.311.0.zip -OutFile actions-runner-win-x64.zip # Extract Expand-Archive -Path actions-runner-win-x64.zip -DestinationPath . -
Configure runner:
.\config.cmd --url https://github.com/YOUR_USERNAME/MQL5-Google-Onedrive --token YOUR_TOKEN -
Run as service:
.\run.cmd
Step 4: Workflow Files
The following workflows are configured:
1. ci-cd-docker-dev.yml
- Builds Docker dev image
- Runs tests
- Deploys to GitHub Container Registry
- Triggers on push to
mainordevelop
2. docker-dev-desktop.yml
- Builds Docker dev image
- Deploys to Docker Desktop (requires self-hosted runner)
- Can be triggered manually
Step 5: Test the Workflow
-
Make a change to trigger the workflow:
git add . git commit -m "Test CI/CD workflow" git push origin develop -
Check workflow status:
- Go to repository → Actions tab
- Click on the running workflow
- Monitor build and deployment steps
Step 6: Manual Deployment
You can also trigger workflows manually:
- Go to Actions tab
- Select workflow (e.g., "Docker Dev Desktop Deployment")
- Click Run workflow
- Select branch and options
- Click Run workflow
Troubleshooting
Workflow Fails to Start
- Check if Actions are enabled in repository settings
- Verify workflow file syntax (YAML)
- Check branch protection rules
Docker Build Fails
- Verify
Dockerfile.devexists - Check Docker syntax
- Review build logs in Actions tab
Deployment Fails
- Ensure Docker Desktop is running (for local deployment)
- Check self-hosted runner status
- Verify secrets are set correctly
Authentication Errors
- Verify GitHub token has correct permissions
- Check if secrets are set correctly
- Ensure email/password are correct (or use PAT)
Security Best Practices
- ✅ Use Personal Access Token instead of password
- ✅ Never commit secrets to repository
- ✅ Use environment-specific secrets
- ✅ Review workflow permissions regularly
- ✅ Enable branch protection for main branch
Next Steps
Support
If you encounter issues:
- Check GitHub Actions logs
- Verify all secrets are set
- Ensure Docker Desktop is running
- Review workflow file syntax