Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
71 changes: 71 additions & 0 deletions .github/workflows/cd_PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Pull Request build+deploy

on:
pull_request:
types: ['opened', 'edited', 'synchronize']
branches:
- '**'

jobs:
deploy:
environment: branch-deploy
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Set up Docker
uses: docker/setup-docker-action@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Setup deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: branch-deploy-${{ github.head_ref }}
ref: ${{ github.head_ref }}

- name: Install dependencies
run: |
pnpm install
pnpm build

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: '.next'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
alias: deploy-preview-${{ github.event.number }}-100xdevs
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1

- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
logs: ${{ steps.deploy-netlify.outputs.netlify_logs_url }}
env_url: ${{ steps.deploy-netlify.outputs.netlify_preview_url }}
56 changes: 56 additions & 0 deletions .github/workflows/pr_deploy_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# name: Cleanup Old Netlify Deployments

# on:
# schedule:
# # Run at 00:00 UTC every Sunday
# - cron: '0 0 * * 0'
# # Optional: Allow manual trigger
# workflow_dispatch:

# jobs:
# cleanup:
# name: Cleanup Old Netlify Deployments
# runs-on: ubuntu-latest
# steps:
# - name: Install Netlify CLI
# run: npm install -g netlify-cli

# - name: Authenticate with Netlify
# run: netlify login --auth ${{ secrets.NETLIFY_AUTH_TOKEN }}

# - name: List and delete old deployments
# run: |
# # Get current date in seconds since epoch
# CURRENT_DATE=$(date +%s)

# # Calculate the cutoff date (60 days ago) in seconds
# SIXTY_DAYS_IN_SECONDS=$((60 * 24 * 60 * 60))
# CUTOFF_DATE=$((CURRENT_DATE - SIXTY_DAYS_IN_SECONDS))

# echo "Fetching deployments for site ${{ secrets.NETLIFY_SITE_ID }}..."

# # List all deployments and filter those older than 60 days
# DEPLOYMENTS=$(netlify api listSiteDeploys --data "{\"site_id\":\"${{ secrets.NETLIFY_SITE_ID }}\"}")

# # Process each deployment
# echo "$DEPLOYMENTS" | jq -c '.[]' | while read -r deploy; do
# DEPLOY_ID=$(echo "$deploy" | jq -r '.id')
# CREATED_AT=$(echo "$deploy" | jq -r '.created_at')

# # Convert ISO date to seconds since epoch
# DEPLOY_DATE=$(date -d "$CREATED_AT" +%s)

# # Calculate age in days for logging
# AGE_DAYS=$(( (CURRENT_DATE - DEPLOY_DATE) / 86400 ))

# # Check if deployment is older than cutoff
# if [ "$DEPLOY_DATE" -lt "$CUTOFF_DATE" ]; then
# echo "Deleting deployment $DEPLOY_ID (created $CREATED_AT, $AGE_DAYS days old)"
# netlify api deleteSiteDeploy --data "{\"site_id\":\"${{ secrets.NETLIFY_SITE_ID }}\",\"deploy_id\":\"$DEPLOY_ID\"}"
# else
# echo "Keeping deployment $DEPLOY_ID (created $CREATED_AT, $AGE_DAYS days old)"
# fi
# done
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}i ajshdkahsdkljhaksjh
6 changes: 6 additions & 0 deletions error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Vercel CLI 41.4.1
Retrieving project…
Deploying kitsunekode-manash/cms
Inspect: https://vercel.com/kitsunekode-manash/cms/14YnZJ5bPtdMcCtpBjZ9jwTBjH8o [3s]
Preview: https://cms-mfu4ij2mk-kitsunekode-manash.vercel.app [3s]
Queued
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"nextjs-toploader": "^1.6.11",
"notion-client": "^6.16.0",
"pdf-lib": "^1.17.1",
"prettier-plugin-tailwindcss": "^0.6.11",
"prismjs": "^1.29.0",
"qs": "^6.13.0",
"react": "^18",
Expand Down Expand Up @@ -106,8 +107,17 @@
"prisma": "^5.18.0",
"tailwindcss": "^3.3.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript": "^5.3.3",
"vitest": "^1.6.0",
"vitest-mock-extended": "^1.3.1"
},
"pnpm": {
"onlyBuiltDependencies": [
"@prisma/client",
"@prisma/engines",
"bcrypt",
"esbuild",
"prisma"
]
}
}
Loading
Loading