-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ahmed-deriv/feature/RestAPI-Platform
Feature/rest api platform
- Loading branch information
Showing
11 changed files
with
612 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: 'Deploy to Vercel Development' | ||
description: 'Deploys the application to Vercel Preview environment' | ||
|
||
inputs: | ||
vercel-token: | ||
description: 'Vercel authentication token' | ||
required: true | ||
vercel-org-id: | ||
description: 'Vercel organization ID' | ||
required: true | ||
vercel-project-id: | ||
description: 'Vercel project ID' | ||
required: true | ||
pr-number: | ||
description: 'Pull request number' | ||
required: true | ||
|
||
outputs: | ||
deployment-url: | ||
description: 'The URL of the deployed application' | ||
value: ${{ steps.deploy.outputs.url }} | ||
deployment-id: | ||
description: 'The ID of the deployment' | ||
value: ${{ steps.deploy.outputs.id }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Pull Vercel Environment Information | ||
shell: bash | ||
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 }} | ||
|
||
- name: Deploy to Vercel | ||
id: deploy | ||
shell: bash | ||
run: | | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: 'Deploy to Vercel Production' | ||
description: 'Deploys the application to Vercel Production environment' | ||
|
||
inputs: | ||
vercel-token: | ||
description: 'Vercel authentication token' | ||
required: true | ||
vercel-org-id: | ||
description: 'Vercel organization ID' | ||
required: true | ||
vercel-project-id: | ||
description: 'Vercel project ID' | ||
required: true | ||
sha: | ||
description: 'Git commit SHA' | ||
required: true | ||
|
||
outputs: | ||
deployment-url: | ||
description: 'The URL of the deployed application' | ||
value: ${{ steps.deploy.outputs.url }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Pull Vercel Environment Information | ||
shell: bash | ||
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 "π Installing all dependencies..." | ||
npm ci --include=dev | ||
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 }} | ||
|
||
- name: Deploy to Vercel | ||
id: deploy | ||
shell: bash | ||
run: | | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: 'Update Deployment Status' | ||
description: 'Updates the deployment status in GitHub' | ||
|
||
inputs: | ||
environment: | ||
description: 'The deployment environment (production/preview)' | ||
required: true | ||
deployment-url: | ||
description: 'The URL of the deployed application' | ||
required: true | ||
sha: | ||
description: 'Git commit SHA' | ||
required: true | ||
status: | ||
description: 'Deployment status (success/failure)' | ||
required: true | ||
description: | ||
description: 'Status description' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Update deployment status | ||
shell: bash | ||
run: | | ||
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') | ||
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") | ||
echo "β Deployment status updated successfully" | ||
echo " - Description: ${{ inputs.description }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: 'Setup Environment' | ||
description: 'Sets up Node.js and installs dependencies' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'npm' | ||
|
||
- 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" |
Oops, something went wrong.