Normalize check titles and descriptions #9
Workflow file for this run
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: Check Migrations | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'src/database/migrations/**' | |
permissions: | |
issues: write | |
pull-requests: write | |
jobs: | |
check-migrations: | |
# Skip this job if the PR include changes for compliance checks | |
if: "!contains(github.event.pull_request.changed_files, 'src/checks/')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check and add comment to PR | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { data: comments } = await github.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}); | |
const commentExists = comments.some(comment => | |
comment.body.includes("It looks like you've made changes to the migrations.") | |
); | |
if (!commentExists) { | |
await github.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. Thanks for your contribution!\n" + | |
"- [ ] Have you run `npm run db:generate-schema` to ensure the updated schemas are included in your PR?\n" + | |
"- [ ] Have you run \`npm run db:migrate\` and then \`npm run db:rollback\` to confirm that rollbacks are working as expected?\n" + | |
"\n" + | |
"Note: Please avoid making changes to existing migration files, as they won't be executed again in deployed environments.\n" | |
}); | |
console.log("Comment added"); | |
} else { | |
console.log("Comment already exists"); | |
} |