Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI/CD pipeline for Vercel and AWS deployment #161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/aws-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy to AWS

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build:api

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
Comment on lines +35 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Document required AWS secrets in repository settings and README

The following AWS secrets are used in the workflows but are not documented in the repository:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION
  • AWS_S3_BUCKET_NAME
  • AWS_CLOUDFRONT_DISTRIBUTION_ID

Please:

  • Configure these secrets in the repository settings
  • Add documentation in the README.md about the required secrets and their purpose for deployment workflows
🔗 Analysis chain

Document required secrets in repository settings

Ensure these required secrets are documented and configured in the repository settings:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION
  • AWS_S3_BUCKET_NAME
  • AWS_CLOUDFRONT_DISTRIBUTION_ID
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# List configured secrets in the repository
gh api repos/{owner}/{repo}/actions/secrets --jq '.secrets[].name' | grep -E 'AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|S3_BUCKET_NAME|CLOUDFRONT_DISTRIBUTION_ID)'

Length of output: 223


Script:

#!/bin/bash
# Search for AWS secret references in workflow files
rg -U 'secrets\.(AWS_[A-Z_]+)' .github/workflows/

Length of output: 626


Script:

#!/bin/bash
# Check if secrets are documented in README or similar files
rg -i "secret|aws.*(key|region|bucket|distribution)" -A 5 -B 5 "README.md" "CONTRIBUTING.md" "docs/"

Length of output: 96


- name: Deploy to AWS
run: |
aws s3 sync ./dist/apps/api s3://${{ secrets.AWS_S3_BUCKET_NAME }}
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 33 additions & 0 deletions .github/workflows/vercel-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to Vercel

on:
push:
branches:
- main
Comment on lines +3 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance workflow triggers for better deployment control

Consider adding:

  1. Pull request trigger for preview deployments
  2. Environment protection for production deployments
 on:
   push:
     branches:
       - main
+  pull_request:
+    types: [opened, synchronize, reopened]
+
+environment:
+  name: production
+  rules:
+    - if: github.ref == 'refs/heads/main'

Committable suggestion skipped: line range outside the PR's diff.


jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install

- name: Build the project
run: npm run build:web-mobile

- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: ./apps/web-mobile
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion apps/web-mobile/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"source": "/(.*)",
"destination": "/"
}
]
],
"buildCommand": "npm run build",
"outputDirectory": "dist/apps/web-mobile",
"framework": "vite"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"start:api": "nx serve api",
"start:contracts": "nx serve contracts",
"start:web-mobile": "nx serve web-mobile",
"update": "nx migrate latest"
"update": "nx migrate latest",
"deploy:vercel": "vercel --prod",
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved
"deploy:aws": "aws s3 sync ./dist/apps/api s3://${{ secrets.AWS_S3_BUCKET_NAME }} && aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths '/*'"
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@eslint/js": "^9.8.0",
Expand Down
Loading