Files
flyer-crawler.projectium.com/.gitea/workflows/sync-test-version.yml
Torben Sorensen fe79522ea4
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 27m44s
pm2 save fix + test work
2026-02-18 15:43:20 -08:00

101 lines
3.5 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# .gitea/workflows/sync-test-version.yml
#
# Lightweight workflow to sync version numbers from production to test environment.
# This runs after successful production deployments to update test PM2 metadata
# without re-running the full test suite, build, and deployment pipeline.
#
# Duration: ~30 seconds (vs 5+ minutes for full test deployment)
name: Sync Test Version
on:
workflow_run:
workflows: ["Deploy to Production"]
types:
- completed
branches:
- main
jobs:
sync-version:
runs-on: projectium.com
# Only run if the production deployment succeeded
if: ${{ gitea.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout Latest Code
uses: actions/checkout@v3
with:
fetch-depth: 1 # Shallow clone, we only need latest commit
- name: Update Test Package Version
run: |
echo "========================================="
echo "SYNCING VERSION TO TEST ENVIRONMENT"
echo "========================================="
APP_PATH="/var/www/flyer-crawler-test.projectium.com"
# Get version from this repo's package.json
NEW_VERSION=$(node -p "require('./package.json').version")
echo "Production version: $NEW_VERSION"
# Get current test version
if [ -f "$APP_PATH/package.json" ]; then
CURRENT_VERSION=$(node -p "require('$APP_PATH/package.json').version")
echo "Current test version: $CURRENT_VERSION"
else
CURRENT_VERSION="unknown"
echo "Test package.json not found"
fi
# Only update if versions differ
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
echo "Updating test package.json to version $NEW_VERSION..."
# Update just the version field in test's package.json
cd "$APP_PATH"
npm version "$NEW_VERSION" --no-git-tag-version --allow-same-version
echo "✅ Test package.json updated to $NEW_VERSION"
else
echo " Versions already match, no update needed"
fi
- name: Restart Test PM2 Processes
run: |
echo "Restarting test PM2 processes to refresh version metadata..."
# Restart with --update-env to pick up new package.json version
pm2 restart flyer-crawler-api-test flyer-crawler-worker-test flyer-crawler-analytics-worker-test --update-env && pm2 save
echo "✅ Test PM2 processes restarted and saved"
# Show current state
echo ""
echo "--- Current PM2 State ---"
pm2 list
# Verify version in PM2 metadata
echo ""
echo "--- Verifying Version in PM2 ---"
pm2 jlist | node -e "
try {
const list = JSON.parse(require('fs').readFileSync(0, 'utf-8'));
const testProcesses = list.filter(p => p.name && p.name.endsWith('-test'));
testProcesses.forEach(p => {
console.log(p.name + ': v' + (p.pm2_env.version || 'unknown') + ' (' + p.pm2_env.status + ')');
});
} catch(e) {
console.error('Failed to parse PM2 output');
}
"
- name: Summary
run: |
echo "========================================="
echo "VERSION SYNC COMPLETE"
echo "========================================="
echo "Test environment version updated to match production"
echo "No tests run, no builds performed"
echo "Duration: ~30 seconds"