-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom render build script
- Fetch latest code from origin main - Check if schema.prisma has changed - Run Prisma generate and migrate commands if schema has changed - Install dependencies using yarn - Build the application
- Loading branch information
1 parent
6afe33c
commit f55b752
Showing
2 changed files
with
47 additions
and
33 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 |
---|---|---|
@@ -1,52 +1,43 @@ | ||
name: Deploy to Render | ||
name: Trigger Deploy to Render | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Check if schema.prisma has changed | ||
id: schema_changed | ||
run: | | ||
git fetch origin main | ||
git diff --exit-code origin/main -- prisma/schema.prisma || echo "schema_changed=true" >> $GITHUB_ENV | ||
- name: Generate Prisma client | ||
if: env.schema_changed == 'true' | ||
run: npx prisma generate | ||
|
||
- name: Create and apply Prisma migrations | ||
if: env.schema_changed == 'true' | ||
run: | | ||
npx prisma migrate dev --name auto-migration | ||
npx prisma migrate deploy | ||
- name: Build the application | ||
run: yarn build | ||
|
||
- name: Deploy to Render | ||
id: deploy | ||
env: | ||
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }} | ||
SERVICE_ID: ${{ secrets.RENDER_SERVICE_ID }} | ||
run: | | ||
curl --request POST \ | ||
response=$(curl --write-out "%{http_code}" --silent --output response.json --request POST \ | ||
--url "https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys" \ | ||
--header "accept: application/json" \ | ||
--header "authorization: Bearer ${{ secrets.RENDER_API_KEY }}" \ | ||
--header "content-type: application/json" | ||
--header "content-type: application/json") | ||
echo "HTTP_RESPONSE=$response" >> $GITHUB_ENV | ||
if [[ "$response" -eq 200 ]]; then | ||
echo "Deployment triggered successfully" | ||
else | ||
echo "Deployment failed" | ||
cat response.json | ||
exit 1 | ||
fi | ||
- name: Success Step | ||
if: success() | ||
run: echo "Deployment was successful" | ||
|
||
- name: Failure Step | ||
if: failure() | ||
run: echo "Deployment failed" |
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,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
git fetch origin main | ||
|
||
# Check if schema.prisma has changed | ||
if git diff --exit-code origin/main -- prisma/schema.prisma; then | ||
echo "schema.prisma has not changed. Skipping Prisma commands." | ||
else | ||
echo "schema.prisma has changed. Running Prisma commands." | ||
|
||
# Generate Prisma client | ||
npx prisma generate | ||
|
||
# Create and apply Prisma migrations | ||
npx prisma migrate dev --name auto-migration | ||
npx prisma migrate deploy | ||
fi | ||
|
||
yarn install --frozen-lockfile | ||
|
||
yarn build |