Skip to content

fix: Make deployment log artifact names unique #122

fix: Make deployment log artifact names unique

fix: Make deployment log artifact names unique #122

name: Integration Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test-deployment:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate unique test name
id: test-name
run: |
# Create unique name with GitHub run number
TEST_NAME="mautic-test-${{ github.run_number }}"
echo "test-name=$TEST_NAME" >> $GITHUB_OUTPUT
echo "🏷️ Test VPS name: $TEST_NAME"
- name: Deploy Mautic (Initial Installation)
id: deploy
uses: ./
with:
vps-name: ${{ steps.test-name.outputs.test-name }}
vps-size: 's-1vcpu-1gb'
vps-region: 'nyc1'
email: 'test@mautic-test.local'
mautic-password: ${{ secrets.TEST_MAUTIC_PASSWORD }}
mysql-password: ${{ secrets.TEST_MYSQL_PASSWORD }}
mysql-root-password: ${{ secrets.TEST_MYSQL_ROOT_PASSWORD }}
digitalocean-token: ${{ secrets.DIGITALOCEAN_TOKEN }}
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# Start with older version for upgrade testing
mautic-version: '6.0.4-apache'
plugins: |
https://github.com/chimpino/stripe-plugin/archive/refs/heads/6.x.zip?directory=StripeBundle&token=${{ secrets.CHIMPINO_GITHUB_TOKEN }}
- name: Show initial deployment results
run: |
echo "πŸŽ‰ Initial deployment completed successfully!"
echo "VPS IP: ${{ steps.deploy.outputs.vps-ip }}"
echo "Mautic URL: ${{ steps.deploy.outputs.mautic-url }}"
echo "βœ… Mautic 6.0.4 installation test passed"
- name: Verify initial deployment is ready
run: |
echo "πŸ” Actively verifying Mautic 6.0.4 is fully ready..."
echo "πŸ› Debug: Checking deployment outputs..."
echo " VPS IP: '${{ steps.deploy.outputs.vps-ip }}'"
echo " Mautic URL: '${{ steps.deploy.outputs.mautic-url }}'"
# Setup SSH for container verification
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
MAUTIC_URL="${{ steps.deploy.outputs.mautic-url }}"
# First verify all containers are running
echo "🐳 Verifying all Docker containers are running correctly..."
CONTAINER_STATUS=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "cd /var/www && docker compose ps --format 'table {{.Name}}\t{{.Status}}\t{{.Health}}'")
echo "$CONTAINER_STATUS"
# Check mautic_db
if echo "$CONTAINER_STATUS" | grep -q "mautic_db.*Up.*healthy"; then
echo "βœ… mautic_db container is running and healthy"
else
echo "❌ mautic_db container is not healthy"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_db --tail 50"
exit 1
fi
# Check mautic_web
if echo "$CONTAINER_STATUS" | grep -q "mautic_web.*Up.*healthy"; then
echo "βœ… mautic_web container is running and healthy"
else
echo "❌ mautic_web container is not healthy"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_web --tail 50"
exit 1
fi
# Check mautic_cron
if echo "$CONTAINER_STATUS" | grep -q "mautic_cron.*Up"; then
echo "βœ… mautic_cron container is running"
else
echo "❌ mautic_cron container is not running"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$VPS_IP "docker logs mautic_cron --tail 50"
exit 1
fi
echo "πŸŽ‰ All expected containers are running correctly!"
# Validate URL before proceeding with accessibility tests
if [ -z "$MAUTIC_URL" ]; then
echo "❌ Error: MAUTIC_URL is empty!"
echo "πŸ” Deploy step outputs:"
echo " - vps-ip: '${{ steps.deploy.outputs.vps-ip }}'"
echo " - mautic-url: '${{ steps.deploy.outputs.mautic-url }}'"
echo " - deployment-log: '${{ steps.deploy.outputs.deployment-log }}'"
exit 1
fi
echo "βœ… MAUTIC_URL is set to: $MAUTIC_URL"
# Wait up to 2 minutes for Mautic to be fully ready
timeout=120
counter=0
while [ $counter -lt $timeout ]; do
echo "⏳ Testing Mautic readiness... (${counter}/${timeout}s)"
# Test login page accessibility - accept both 200 and 302 as success
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${MAUTIC_URL}/s/login" 2>/dev/null || echo "000")
echo "πŸ” HTTP response code: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "βœ… Mautic is responding (HTTP $HTTP_CODE)"
# For 302 redirects, this is normal for fresh Mautic installations
if [ "$HTTP_CODE" = "302" ]; then
echo "πŸ“‹ HTTP 302 detected - Mautic is redirecting (normal for fresh installation)"
echo "βœ… Mautic application is ready for setup!"
break
fi
# For 200 responses, verify the page contains expected Mautic content
if curl -s "${MAUTIC_URL}/s/login" | grep -q -i "mautic\|login"; then
echo "βœ… Mautic application is fully ready!"
break
else
echo "⚠️ Page accessible but content not ready yet..."
fi
else
echo "⚠️ Mautic not yet accessible (HTTP $HTTP_CODE)..."
fi
sleep 5
counter=$((counter + 5))
done
if [ $counter -ge $timeout ]; then
echo "❌ Timeout waiting for Mautic to be ready"
echo "πŸ” Final check - attempting to access ${MAUTIC_URL}/s/login"
curl -v "${MAUTIC_URL}/s/login" || echo "Failed to access Mautic"
exit 1
fi
echo "πŸŽ‰ Initial deployment verification completed - ready for upgrade test!"
- name: Verify plugin installation
run: |
echo "πŸ” Verifying plugins were installed correctly..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
if [ -z "$VPS_IP" ]; then
echo "❌ Error: VPS_IP is empty!"
exit 1
fi
# Check if the plugin directories exist and contain expected files
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} << 'EOF'
echo "πŸ“‚ Checking plugin directory structure..."
plugin_success=0
# Check StripeBundle (private repo with token)
if docker exec mautic_web ls /var/www/html/docroot/plugins/StripeBundle >/dev/null 2>&1; then
echo "βœ… StripeBundle directory found"
if docker exec mautic_web find /var/www/html/docroot/plugins/StripeBundle -name "*.php" | head -1 | grep -q ".php"; then
echo "βœ… StripeBundle contains PHP files - installation successful"
plugin_success=$((plugin_success + 1))
else
echo "⚠️ StripeBundle directory exists but no PHP files found"
echo "πŸ” Debug: Contents of StripeBundle directory:"
docker exec mautic_web ls -la /var/www/html/docroot/plugins/StripeBundle/ || echo "Failed to list directory contents"
echo "πŸ” Debug: Looking for any files in StripeBundle:"
docker exec mautic_web find /var/www/html/docroot/plugins/StripeBundle -type f | head -10 || echo "No files found"
echo "πŸ” Debug: Directory size and file count:"
docker exec mautic_web bash -c 'du -sh /var/www/html/docroot/plugins/StripeBundle/ && find /var/www/html/docroot/plugins/StripeBundle -type f | wc -l' || echo "Failed to get directory info"
fi
else
echo "⚠️ StripeBundle directory not found (check CHIMPINO_GITHUB_TOKEN secret)"
fi
echo "πŸ“‹ Available plugin directories:"
docker exec mautic_web ls -la /var/www/html/docroot/plugins/ || echo "No plugins directory found"
if [ $plugin_success -gt 0 ]; then
echo "βœ… Plugin installation verification completed ($plugin_success plugins successful)"
exit 0
else
echo "❌ No plugins were installed successfully"
exit 1
fi
EOF
echo "πŸŽ‰ Plugin verification completed successfully!"
- name: Test plugin accessibility via Mautic
run: |
echo "πŸ” Testing if Mautic recognizes the installed plugins..."
VPS_IP="${{ steps.deploy.outputs.vps-ip }}"
# Check plugin status through Mautic console (if available)
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} << 'EOF'
cd /var/www
echo "πŸ”§ Testing Mautic plugin recognition..."
# Check if plugin files are accessible from container
plugin_count=0
if docker exec mautic_web ls /var/www/html/plugins/StripeBundle/ >/dev/null 2>&1; then
echo "βœ… StripeBundle files are accessible from Mautic container"
plugin_count=$((plugin_count + 1))
else
echo "ℹ️ StripeBundle not accessible from container"
fi
if docker exec mautic_web ls /var/www/html/plugins/IntegrationsPlugin/ >/dev/null 2>&1; then
echo "βœ… IntegrationsPlugin files are accessible from Mautic container"
plugin_count=$((plugin_count + 1))
else
echo "ℹ️ IntegrationsPlugin not accessible from container"
fi
echo "πŸ“Š Summary: $plugin_count plugins accessible from container"
# List all available plugins
echo "πŸ“‹ All plugins in container:"
docker exec mautic_web find /var/www/html/docroot/plugins -maxdepth 1 -type d | tail -n +2 | head -10 || echo "No plugins found in container"
EOF
- name: Setup SSH for manual upgrade test
run: |
echo "πŸ” Setting up SSH for manual upgrade testing..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Test version upgrade and resize via action re-run
id: upgrade
uses: ./
with:
vps-name: ${{ steps.test-name.outputs.test-name }}
vps-size: 's-1vcpu-2gb' # Upgrade from 1GB to 2GB
vps-region: 'nyc1'
email: 'test@mautic-test.local'
mautic-password: ${{ secrets.TEST_MAUTIC_PASSWORD }}
mysql-password: ${{ secrets.TEST_MYSQL_PASSWORD }}
mysql-root-password: ${{ secrets.TEST_MYSQL_ROOT_PASSWORD }}
digitalocean-token: ${{ secrets.DIGITALOCEAN_TOKEN }}
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# Upgrade to newer version
mautic-version: '6.0.5-apache'
plugins: |
https://github.com/chimpino/stripe-plugin/archive/refs/heads/6.x.zip?directory=StripeBundle&token=${{ secrets.CHIMPINO_GITHUB_TOKEN }}
- name: Show upgrade and resize results
run: |
echo "πŸŽ‰ Upgrade and resize completed successfully!"
echo "VPS IP: ${{ steps.upgrade.outputs.vps-ip }}"
echo "Mautic URL: ${{ steps.upgrade.outputs.mautic-url }}"
echo "βœ… Mautic 6.0.5 upgrade + resize to 2GB test passed"
- name: Verify upgrade and resize worked
run: |
echo "πŸ” Verifying the upgrade and resize were successful..."
VPS_IP="${{ steps.upgrade.outputs.vps-ip }}"
MAUTIC_URL="${{ steps.upgrade.outputs.mautic-url }}"
# Setup SSH
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Download deployment log to check for resize
echo "πŸ“₯ Downloading deployment log..."
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP}:/var/log/setup-dc.log ./upgrade-test.log || echo "Could not download log"
# Check if resize was detected and executed
if [ -f ./upgrade-test.log ]; then
echo "πŸ“‹ Checking for droplet resize indicators..."
if grep -q "Droplet size mismatch detected" ./upgrade-test.log; then
echo "βœ… PASS: Droplet size mismatch was detected"
if grep -q "Droplet resized successfully" ./upgrade-test.log; then
echo "βœ… PASS: Droplet resize completed successfully"
else
echo "❌ FAIL: Droplet resize did not complete"
echo "πŸ“‹ Log excerpt:"
grep -A 5 -B 5 "resize" ./upgrade-test.log || echo "No resize info found"
exit 1
fi
else
echo "❌ FAIL: No resize detection found in logs"
echo "πŸ“‹ Checking deploy.sh log for resize-related messages..."
grep -i "resize\|size\|checking if droplet" ./upgrade-test.log | head -20 || echo "No size-related messages found"
exit 1
fi
else
echo "⚠️ WARNING: Could not retrieve deployment log"
fi
# Verify Mautic is still working after upgrade and resize
echo "πŸ” Testing Mautic accessibility after upgrade and resize..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${MAUTIC_URL}/s/login" 2>/dev/null || echo "000")
echo "πŸ“‹ HTTP response code: $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "βœ… PASS: Mautic is still accessible after upgrade (HTTP $HTTP_CODE)"
# Check that it's actually the new version by inspecting container
echo "πŸ” Verifying container is running new version..."
CONTAINER_IMAGE=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@${VPS_IP} "docker inspect mautic_web --format='{{.Config.Image}}' 2>/dev/null || echo 'unknown'")
echo "πŸ“¦ Container image: $CONTAINER_IMAGE"
if echo "$CONTAINER_IMAGE" | grep -q "6.0.5-apache"; then
echo "βœ… PASS: Container is running Mautic 6.0.5-apache"
else
echo "❌ FAIL: Container is not running expected version"
exit 1
fi
# Verify droplet was actually resized
echo "πŸ” Verifying droplet size via doctl..."
doctl auth init --access-token "${{ secrets.DIGITALOCEAN_TOKEN }}"
ACTUAL_SIZE=$(doctl compute droplet get "${{ steps.test-name.outputs.test-name }}" --format Size --no-header)
echo "πŸ“Š Actual droplet size: $ACTUAL_SIZE"
if [ "$ACTUAL_SIZE" = "s-1vcpu-2gb" ]; then
echo "βœ… PASS: Droplet is now 2GB"
else
echo "❌ FAIL: Droplet is still $ACTUAL_SIZE (expected s-1vcpu-2gb)"
exit 1
fi
else
echo "❌ FAIL: Mautic is not accessible after upgrade"
exit 1
fi
echo "πŸŽ‰ All version upgrade and resize validation checks passed!"
echo "🏁 Integration test completed successfully:"
echo " βœ… Initial deployment with Mautic 6.0.4 on 1GB droplet"
echo " βœ… Droplet resized from 1GB to 2GB"
echo " βœ… Version upgrade to 6.0.5 without reinstallation"
echo " βœ… Proper maintenance and migration execution"
echo " βœ… Container version verification"
echo " βœ… Droplet size verification"
- name: Cleanup test droplet
if: always()
run: |
echo "🧹 Cleaning up test droplet..."
TEST_NAME="${{ steps.test-name.outputs.test-name }}"
# Install doctl
doctl auth init --access-token "${{ secrets.DIGITALOCEAN_TOKEN }}"
# Delete the test droplet
if doctl compute droplet list | grep -q "$TEST_NAME"; then
echo "Deleting droplet: $TEST_NAME"
doctl compute droplet delete "$TEST_NAME" --force
echo "βœ… Test droplet deleted"
else
echo "ℹ️ Test droplet not found (may have failed to create)"
fi
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-logs-${{ github.run_number }}
path: |
./setup-dc.log
./deploy.env
if-no-files-found: warn
retention-days: 7