Skip to content

Commit

Permalink
fix: added logs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vinu-deriv committed Jan 20, 2025
1 parent bc4c678 commit 928bb27
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 11 deletions.
42 changes: 39 additions & 3 deletions .github/actions/deploy/vercel/development/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,47 @@ runs:
steps:
- name: Pull Vercel Environment Information
shell: bash
run: vercel pull --yes --environment=preview --token=${{ inputs.vercel-token }}
run: |
echo "πŸ”„ Pulling Vercel environment information..."
echo " - Environment: Preview"
echo " - PR Number: ${{ inputs.pr-number }}"
vercel pull --yes --environment=preview --token=${{ inputs.vercel-token }}
echo "βœ… Successfully pulled Vercel environment information"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}

- name: Build Project
shell: bash
run: |
echo "πŸ—οΈ Starting build process for preview deployment..."
echo "πŸ“ Exporting environment variables..."
# Export all GitHub secrets as environment variables
for secret in $(env | grep "GITHUB_.*=" | cut -d= -f1); do
echo " - Exporting $secret"
echo "$secret=${!secret}" >> $GITHUB_ENV
done
for secret in $(env | grep "INPUT_.*=" | cut -d= -f1); do
# Convert INPUT_VERCEL_TOKEN to VERCEL_TOKEN etc.
clean_name=$(echo "$secret" | sed 's/^INPUT_//' | tr '[:upper:]' '[:lower:]')
echo " - Converting and exporting $secret as $clean_name"
echo "$clean_name=${!secret}" >> $GITHUB_ENV
done
echo "πŸš€ Running build command..."
npm run build
echo "πŸ“¦ Checking build output..."
if [ -d "dist" ]; then
echo " - dist directory exists"
echo " - Contents of dist directory:"
ls -la dist/
else
echo "❌ dist directory not found!"
exit 1
fi
echo "βœ… Preview build completed successfully"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}
Expand All @@ -54,12 +77,25 @@ runs:
id: deploy
shell: bash
run: |
cd dist
DEPLOYMENT=$(vercel deploy --cwd . --token=${{ inputs.vercel-token }} --yes)
echo "πŸš€ Starting Vercel preview deployment..."
echo "πŸ“‚ Deploying dist directory..."
echo " - Current directory contents:"
ls -la dist/
echo "☁️ Deploying to Vercel preview environment..."
DEPLOYMENT=$(vercel deploy --cwd dist --token=${{ inputs.vercel-token }} --yes)
DEPLOYMENT_URL="$DEPLOYMENT"
DEPLOYMENT_ID=$(echo "$DEPLOYMENT" | rev | cut -d'/' -f1 | rev)
echo " - Deployment URL: $DEPLOYMENT_URL"
echo " - Deployment ID: $DEPLOYMENT_ID"
echo "πŸ’Ύ Saving deployment information..."
echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
echo "id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
echo "βœ… Preview deployment completed successfully"
echo "🌍 Preview URL: $DEPLOYMENT_URL"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}
38 changes: 35 additions & 3 deletions .github/actions/deploy/vercel/production/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,45 @@ runs:
steps:
- name: Pull Vercel Environment Information
shell: bash
run: vercel pull --yes --environment=production --token=${{ inputs.vercel-token }}
run: |
echo "πŸ”„ Pulling Vercel environment information..."
vercel pull --yes --environment=production --token=${{ inputs.vercel-token }}
echo "βœ… Successfully pulled Vercel environment information"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}

- name: Build Project
shell: bash
run: |
echo "πŸ—οΈ Starting build process..."
echo "πŸ“ Exporting environment variables..."
# Export all GitHub secrets as environment variables
for secret in $(env | grep "GITHUB_.*=" | cut -d= -f1); do
echo " - Exporting $secret"
echo "$secret=${!secret}" >> $GITHUB_ENV
done
for secret in $(env | grep "INPUT_.*=" | cut -d= -f1); do
# Convert INPUT_VERCEL_TOKEN to VERCEL_TOKEN etc.
clean_name=$(echo "$secret" | sed 's/^INPUT_//' | tr '[:upper:]' '[:lower:]')
echo " - Converting and exporting $secret as $clean_name"
echo "$clean_name=${!secret}" >> $GITHUB_ENV
done
echo "πŸš€ Running build command..."
npm run build
echo "πŸ“¦ Checking build output..."
if [ -d "dist" ]; then
echo " - dist directory exists"
echo " - Contents of dist directory:"
ls -la dist/
else
echo "❌ dist directory not found!"
exit 1
fi
echo "βœ… Build completed successfully"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}
Expand All @@ -51,9 +72,20 @@ runs:
id: deploy
shell: bash
run: |
cd dist
DEPLOYMENT_URL=$(vercel deploy --cwd . --prod --token=${{ inputs.vercel-token }} --yes)
echo "πŸš€ Starting Vercel deployment..."
echo "πŸ“‚ Deploying dist directory..."
echo " - Current directory contents:"
ls -la dist/
echo "☁️ Deploying to Vercel..."
DEPLOYMENT_URL=$(vercel deploy --cwd dist --prod --token=${{ inputs.vercel-token }} --yes)
echo " - Deployment URL: $DEPLOYMENT_URL"
echo "πŸ’Ύ Saving deployment URL..."
echo "url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
echo "βœ… Deployment completed successfully"
echo "🌍 Production URL: $DEPLOYMENT_URL"
env:
VERCEL_ORG_ID: ${{ inputs.vercel-org-id }}
VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }}
21 changes: 16 additions & 5 deletions .github/actions/deployment-status/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ runs:
- name: Update deployment status
shell: bash
run: |
# Create deployment
echo "πŸ”„ Updating deployment status..."
echo " - Environment: ${{ inputs.environment }}"
echo " - Status: ${{ inputs.status }}"
echo " - URL: ${{ inputs.deployment-url }}"
echo " - Commit SHA: ${{ inputs.sha }}"
echo "πŸ“ Creating deployment record..."
DEPLOYMENT_ID=$(curl -s -X POST \
-H "Authorization: token ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"ref\":\"${{ inputs.sha }}\",\"environment\":\"${{ inputs.environment }}\",\"auto_merge\":false}" \
"https://api.github.com/repos/${{ github.repository }}/deployments" | jq -r '.id')
# Update deployment status
curl -s -X POST \
echo " - Created deployment with ID: $DEPLOYMENT_ID"
echo "πŸ“€ Updating deployment status..."
STATUS_RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"state\":\"${{ inputs.status }}\",\"environment_url\":\"${{ inputs.deployment-url }}\",\"description\":\"${{ inputs.description }}\"}" \
"https://api.github.com/repos/${{ github.repository }}/deployments/$DEPLOYMENT_ID/statuses"
"https://api.github.com/repos/${{ github.repository }}/deployments/$DEPLOYMENT_ID/statuses")
echo "βœ… Deployment status updated successfully"
echo " - Description: ${{ inputs.description }}"
17 changes: 17 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,22 @@ runs:
- name: Install dependencies
shell: bash
run: |
echo "πŸ”§ Setting up environment..."
echo "πŸ“¦ Node.js version:"
node --version
echo "πŸ“¦ NPM version:"
npm --version
echo "πŸ“₯ Installing dependencies..."
npm ci
echo "πŸ”§ Installing Vercel CLI..."
npm install --global vercel@latest
echo " - Vercel CLI version:"
vercel --version
echo "πŸ“‹ Listing installed packages:"
npm list --depth=0
echo "βœ… Environment setup completed successfully"

0 comments on commit 928bb27

Please sign in to comment.