Skip to content

Commit

Permalink
fix: simplify the check migrations script
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon committed Dec 3, 2024
1 parent 24ef27e commit 9a87a3c
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,37 @@ name: Check Migrations
on:
pull_request:
types: [opened, synchronize]
paths:
- 'src/database/migrations/**'

jobs:
check-migrations:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Check for migration changes
id: check_migrations
run: |
git diff --name-only origin/main...HEAD | grep '^src/database/migrations/' || echo "no-changes" > no_changes
- name: Check and add comment to PR
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
- name: Add comment to PR
if: steps.check_migrations.outputs.changes != 'no-changes'
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "It looks like you've made changes to the migrations. Have you run `npm run db:generate-schema` to ensure the updated schemas are included in your PR?"
})
const commentExists = comments.some(comment =>
comment.body.includes("It looks like you've made changes to the migrations.")
);
if (!commentExists) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: "It looks like you've made changes to the migrations. Have you run `npm run db:generate-schema` to ensure the updated schemas are included in your PR?"
});
}

0 comments on commit 9a87a3c

Please sign in to comment.