From 4cf6f96ade600f12f534ee0b0ed33e2219fbb722 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Jun 2025 20:53:42 +0100 Subject: [PATCH 1/5] Enhance Vercel deployment workflow with improved success messages and deployment summary, including quick test links for frontend and backend integration --- .github/workflows/deploy-vercel-fullstack.yml | 92 ++++++++++++++++++- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-vercel-fullstack.yml b/.github/workflows/deploy-vercel-fullstack.yml index e241c769b..6cf004b21 100644 --- a/.github/workflows/deploy-vercel-fullstack.yml +++ b/.github/workflows/deploy-vercel-fullstack.yml @@ -50,7 +50,10 @@ jobs: fi echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT - echo "Backend deployed to: $DEPLOYMENT_URL" + echo "" + echo "๐ŸŽฏ BACKEND DEPLOYED SUCCESSFULLY!" + echo "๐Ÿ“ Backend URL: $DEPLOYMENT_URL" + echo "" env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_PROJECT_ID }} @@ -142,7 +145,11 @@ jobs: echo "Setting VITE_API_BASE_URL to: ${{ needs.deploy-backend.outputs.backend-url }}" DEPLOYMENT_URL=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --build-env VITE_API_BASE_URL=${{ needs.deploy-backend.outputs.backend-url }}) echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT - echo "Frontend deployed to: $DEPLOYMENT_URL" + echo "" + echo "๐ŸŒŸ FRONTEND DEPLOYED SUCCESSFULLY!" + echo "๐Ÿ”— Frontend URL: $DEPLOYMENT_URL" + echo "๐Ÿ”Œ Connected to Backend: ${{ needs.deploy-backend.outputs.backend-url }}" + echo "" env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_FRONTEND_PROJECT_ID }} @@ -166,4 +173,83 @@ jobs: -X OPTIONS \ "$BACKEND_URL/api/setup/health/hello" -v || echo "CORS preflight failed" - echo "โœ… Integration test completed. Check browser console for frontend logs." \ No newline at end of file + echo "โœ… Integration test completed. Check browser console for frontend logs." + + - name: ๐Ÿš€ Deployment Summary + run: | + FRONTEND_URL="${{ steps.deploy-frontend.outputs.url }}" + BACKEND_URL="${{ needs.deploy-backend.outputs.backend-url }}" + + echo "" + echo "======================================================" + echo "๐ŸŽ‰ DEPLOYMENT SUCCESSFUL! ๐ŸŽ‰" + echo "======================================================" + echo "" + echo "๐ŸŒ FRONTEND: $FRONTEND_URL" + echo "โšก BACKEND: $BACKEND_URL" + echo "" + echo "๐Ÿ“ Quick Test Links:" + echo " โ€ข Frontend App: $FRONTEND_URL" + echo " โ€ข Backend Health: $BACKEND_URL/api/health" + echo " โ€ข Backend API: $BACKEND_URL/api" + echo "" + echo "โœ… Both services are deployed and integrated!" + echo "======================================================" + + # Create GitHub Actions Summary + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ๐Ÿš€ Deployment Successful! + + Your branch has been successfully deployed to Vercel preview environments: + + ### ๐ŸŒ Frontend Application + **URL:** [$FRONTEND_URL]($FRONTEND_URL) + + ### โšก Backend API + **URL:** [$BACKEND_URL]($BACKEND_URL) + + ### ๐Ÿงช Quick Test Links + - [Frontend App]($FRONTEND_URL) - Main application interface + - [Backend Health Check]($BACKEND_URL/api/health) - API health status + - [Backend API Base]($BACKEND_URL/api) - API documentation + + ### โœ… Integration Status + Both frontend and backend are deployed and properly connected! + + --- + *This deployment will be available until the PR is closed or merged.* + EOF + + - name: ๐Ÿ’ฌ Comment PR with deployment URLs + uses: actions/github-script@v7 + with: + script: | + const frontendUrl = '${{ steps.deploy-frontend.outputs.url }}'; + const backendUrl = '${{ needs.deploy-backend.outputs.backend-url }}'; + + const comment = `## ๐Ÿš€ Preview Deployment Ready! + + Your changes have been deployed and are ready for testing: + + ### ๐ŸŒ Frontend Application + **Live Preview:** [${frontendUrl}](${frontendUrl}) + + ### โšก Backend API + **API Endpoint:** [${backendUrl}](${backendUrl}) + + ### ๐Ÿงช Quick Test Links + - [๐Ÿ“ฑ Frontend App](${frontendUrl}) - Test the user interface + - [โค๏ธ Backend Health](${backendUrl}/api/health) - Verify API status + - [๐Ÿ“š API Documentation](${backendUrl}/api) - Explore endpoints + + --- + โœ… **Integration Status:** Frontend and backend are connected and ready for testing! + + *๐Ÿ”„ This preview will update automatically when you push new commits to this PR.*`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); \ No newline at end of file From 344365defc991b1bc2c9782ffe0664b9946fc077 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Jun 2025 20:55:28 +0100 Subject: [PATCH 2/5] Update Vercel deployment workflow to enhance PR comment handling by updating existing comments or creating new ones, improving clarity on deployment status. --- .github/workflows/deploy-vercel-fullstack.yml | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-vercel-fullstack.yml b/.github/workflows/deploy-vercel-fullstack.yml index 6cf004b21..db9ecb537 100644 --- a/.github/workflows/deploy-vercel-fullstack.yml +++ b/.github/workflows/deploy-vercel-fullstack.yml @@ -220,14 +220,14 @@ jobs: *This deployment will be available until the PR is closed or merged.* EOF - - name: ๐Ÿ’ฌ Comment PR with deployment URLs + - name: ๐Ÿ’ฌ Update PR with deployment URLs uses: actions/github-script@v7 with: script: | const frontendUrl = '${{ steps.deploy-frontend.outputs.url }}'; const backendUrl = '${{ needs.deploy-backend.outputs.backend-url }}'; - const comment = `## ๐Ÿš€ Preview Deployment Ready! + const commentBody = `## ๐Ÿš€ Preview Deployment Ready! Your changes have been deployed and are ready for testing: @@ -245,11 +245,37 @@ jobs: --- โœ… **Integration Status:** Frontend and backend are connected and ready for testing! - *๐Ÿ”„ This preview will update automatically when you push new commits to this PR.*`; + *๐Ÿ”„ Last updated: ${new Date().toLocaleString()} UTC* + + `; - github.rest.issues.createComment({ + // Find existing deployment comment + const comments = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: comment - }); \ No newline at end of file + }); + + const existingComment = comments.data.find(comment => + comment.body.includes('') + ); + + if (existingComment) { + // Update existing comment + await github.rest.issues.updateComment({ + comment_id: existingComment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + console.log('โœ… Updated existing deployment comment'); + } else { + // Create new comment if none exists + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + console.log('โœ… Created new deployment comment'); + } \ No newline at end of file From ebafc8c3402129d84c3c46e2edfe06d110e4e017 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Jun 2025 21:00:44 +0100 Subject: [PATCH 3/5] Add permissions to Vercel deployment workflow for enhanced access control on contents, pull requests, and issues --- .github/workflows/deploy-vercel-fullstack.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy-vercel-fullstack.yml b/.github/workflows/deploy-vercel-fullstack.yml index db9ecb537..47b34999a 100644 --- a/.github/workflows/deploy-vercel-fullstack.yml +++ b/.github/workflows/deploy-vercel-fullstack.yml @@ -4,6 +4,11 @@ on: pull_request: types: [opened, synchronize, reopened] +permissions: + contents: read + pull-requests: write + issues: write + jobs: deploy-backend: runs-on: ubuntu-latest From 0d94aa99ed70b89cf2c54b900e306523b85a85dc Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Jun 2025 21:03:51 +0100 Subject: [PATCH 4/5] Refactor Vercel deployment workflow to streamline token handling and improve deployment commands, enhancing overall efficiency and clarity --- .github/workflows/deploy-vercel-fullstack.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-vercel-fullstack.yml b/.github/workflows/deploy-vercel-fullstack.yml index 47b34999a..1c90dfebc 100644 --- a/.github/workflows/deploy-vercel-fullstack.yml +++ b/.github/workflows/deploy-vercel-fullstack.yml @@ -44,14 +44,17 @@ jobs: mkdir -p .vercel echo "{\"orgId\":\"$VERCEL_ORG_ID\",\"projectId\":\"$VERCEL_PROJECT_ID\"}" > .vercel/project.json + # Set token environment variable for Vercel CLI + export VERCEL_TOKEN="${{ secrets.VERCEL_TOKEN }}" + # Try vercel pull first, if it fails, proceed with direct deployment - if vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}; then + if vercel pull --yes --environment=preview; then echo "โœ… Successfully pulled Vercel configuration" - vercel build --token=${{ secrets.VERCEL_TOKEN }} - DEPLOYMENT_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) + vercel build + DEPLOYMENT_URL=$(vercel deploy --prebuilt) else echo "โš ๏ธ Vercel pull failed, proceeding with direct deployment" - DEPLOYMENT_URL=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }}) + DEPLOYMENT_URL=$(vercel deploy) fi echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT @@ -62,6 +65,7 @@ jobs: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - name: Debug backend deployment outputs run: | @@ -145,10 +149,13 @@ jobs: echo "Dist folder contents:" ls -la dist/ + # Set token environment variable for Vercel CLI + export VERCEL_TOKEN="${{ secrets.VERCEL_TOKEN }}" + # Deploy from current directory with backend URL as environment variable echo "Deploying frontend to Vercel..." echo "Setting VITE_API_BASE_URL to: ${{ needs.deploy-backend.outputs.backend-url }}" - DEPLOYMENT_URL=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --build-env VITE_API_BASE_URL=${{ needs.deploy-backend.outputs.backend-url }}) + DEPLOYMENT_URL=$(vercel deploy --build-env VITE_API_BASE_URL=${{ needs.deploy-backend.outputs.backend-url }}) echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT echo "" echo "๐ŸŒŸ FRONTEND DEPLOYED SUCCESSFULLY!" @@ -158,6 +165,7 @@ jobs: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_FRONTEND_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - name: Test integration run: | From 766685e0cc5581560d1ce353832dd03c124a477f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Jun 2025 21:09:33 +0100 Subject: [PATCH 5/5] Enhance Vercel deployment workflow by implementing explicit token handling and improving deployment command structure, ensuring more reliable and secure deployments. --- .github/workflows/deploy-vercel-fullstack.yml | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-vercel-fullstack.yml b/.github/workflows/deploy-vercel-fullstack.yml index 1c90dfebc..c7e70ac00 100644 --- a/.github/workflows/deploy-vercel-fullstack.yml +++ b/.github/workflows/deploy-vercel-fullstack.yml @@ -40,21 +40,28 @@ jobs: cd backend echo "Deploying backend to Vercel..." echo "Setting up Vercel project linking..." + # Ensure .vercel directory exists and create project.json mkdir -p .vercel echo "{\"orgId\":\"$VERCEL_ORG_ID\",\"projectId\":\"$VERCEL_PROJECT_ID\"}" > .vercel/project.json - # Set token environment variable for Vercel CLI - export VERCEL_TOKEN="${{ secrets.VERCEL_TOKEN }}" + # Debug: Check if token is available (first 10 chars only for security) + echo "Token check: ${VERCEL_TOKEN:0:10}..." + + # Explicitly set token in multiple ways for Vercel CLI + export VERCEL_TOKEN="$VERCEL_TOKEN" + + # Use explicit token parameter as backup + TOKEN_ARG="--token=$VERCEL_TOKEN" # Try vercel pull first, if it fails, proceed with direct deployment - if vercel pull --yes --environment=preview; then + if vercel pull --yes --environment=preview $TOKEN_ARG; then echo "โœ… Successfully pulled Vercel configuration" - vercel build - DEPLOYMENT_URL=$(vercel deploy --prebuilt) + vercel build $TOKEN_ARG + DEPLOYMENT_URL=$(vercel deploy --prebuilt $TOKEN_ARG) else echo "โš ๏ธ Vercel pull failed, proceeding with direct deployment" - DEPLOYMENT_URL=$(vercel deploy) + DEPLOYMENT_URL=$(vercel deploy $TOKEN_ARG) fi echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT @@ -149,13 +156,19 @@ jobs: echo "Dist folder contents:" ls -la dist/ - # Set token environment variable for Vercel CLI - export VERCEL_TOKEN="${{ secrets.VERCEL_TOKEN }}" + # Debug: Check if token is available (first 10 chars only for security) + echo "Token check: ${VERCEL_TOKEN:0:10}..." + + # Explicitly set token in multiple ways for Vercel CLI + export VERCEL_TOKEN="$VERCEL_TOKEN" + + # Use explicit token parameter as backup + TOKEN_ARG="--token=$VERCEL_TOKEN" # Deploy from current directory with backend URL as environment variable echo "Deploying frontend to Vercel..." echo "Setting VITE_API_BASE_URL to: ${{ needs.deploy-backend.outputs.backend-url }}" - DEPLOYMENT_URL=$(vercel deploy --build-env VITE_API_BASE_URL=${{ needs.deploy-backend.outputs.backend-url }}) + DEPLOYMENT_URL=$(vercel deploy $TOKEN_ARG --build-env VITE_API_BASE_URL=${{ needs.deploy-backend.outputs.backend-url }}) echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT echo "" echo "๐ŸŒŸ FRONTEND DEPLOYED SUCCESSFULLY!"