feat: fix #10
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
name: Update Prisma Schema | |
on: | |
push: | |
branches: | |
- main | |
#schedule: | |
# Runs every 30 minutes | |
#- cron: "*/2 * * * *" | |
jobs: | |
update-schema: | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm --recursive install --no-frozen-lockfile | |
- name: Update Prisma Schema | |
run: npx prisma db pull | |
working-directory: packages/api | |
- name: Regenerate Prisma Client | |
run: npx prisma generate | |
working-directory: packages/api | |
- name: Check if there are changes | |
id: git-check | |
run: | | |
git diff --exit-code || echo "::set-output name=changes_detected::true" | |
- name: Commit changes | |
if: steps.git-check.outputs.changes_detected == 'true' | |
run: | | |
git config --global user.name 'Panora-Prisma Updates Bot' | |
git add . | |
git commit -m "Update Prisma schema" | |
- name: Create Pull Request | |
if: steps.git-check.outputs.changes_detected == 'true' | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
commit-message: Update Prisma schema | |
title: "chore: Update Prisma schema" | |
body: "This PR was auto-generated by GitHub Actions & Panora-Prisma." | |
branch: "update-prisma-schema-${{ github.run_id }}" | |
- name: Auto-merge Pull Request | |
if: steps.git-check.outputs.changes_detected == 'true' | |
uses: pascalgn/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
mergeMethod: squash | |
commitMessage: "chore: Update Prisma schema" | |
pullRequestFilterLabels: "auto-merge" | |
requiredLabels: "auto-merge" | |
blockingLabels: "do not merge" | |
requiredChecks: "release,build-api (16.x)" |