-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Migrations Reminder GitHub actions
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# GitHub action that checks if the PR contains changes related to migrations an add reminder comment to the PR. | ||
# Based on https://github.com/marketplace/actions/changed-files | ||
|
||
name: Migrations Reminder | ||
|
||
on: | ||
pull_request | ||
|
||
jobs: | ||
check_changed_files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Group files that have changed | ||
id: changed-files-yaml | ||
uses: tj-actions/changed-files@v41 | ||
with: | ||
files_yaml: | | ||
linters: | ||
- '.github/workflows/isolated_migrations.yml' | ||
- 'src/api/.rubocop*.yml' | ||
migrations: | ||
- src/api/db/migrate/** | ||
- src/api/db/schema.rb | ||
- src/api/db/data/** | ||
- src/api/db/data_schema.rb | ||
not_migrations: | ||
- '!src/api/db/migrate/**' | ||
- '!src/api/db/schema.rb' | ||
- '!src/api/db/data/**' | ||
- '!src/api/db/data_schema.rb' | ||
- '!src/api/db/attribute_descriptions.rb' | ||
- '!src/api/db/seeds.rb' | ||
- '!.github/workflows/isolated_migrations.yml' | ||
- '!src/api/.rubocop*.yml' | ||
schema_migrations: | ||
- src/api/db/migrate/** | ||
data_migrations: | ||
- src/api/db/data/** | ||
schema: | ||
- src/api/db/schema.rb | ||
data_schema: | ||
- src/api/db/data_schema.rb | ||
- name: Check if the Pull Request contains code changes together with migrations | ||
if: (steps.changed-files-yaml.outputs.migrations_any_changed == 'true') && (steps.changed-files-yaml.outputs.not_migrations_all_changed_files_count > 0) | ||
run: | | ||
echo "There are code changes together with migrations. Please split them into two Pull Requests" | ||
exit 1 | ||
- name: Comment Pull Request | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: (steps.changed-files-yaml.outputs.migrations_any_changed == 'true') && (steps.changed-files-yaml.outputs.not_migrations_all_changed_files_count > 0) | ||
with: | ||
message: | | ||
:warning: This pull request contains migrations. Migrations and code changes should be shipped independently. | ||
- name: Missing schema changes | ||
if: (steps.changed-files-yaml.outputs.schema_migrations_added_files == 'true') && (steps.changed-files-yaml.outputs.linters_any_changed == 'false') && (steps.changed-files-yaml.outputs.schema_any_changed == 'false') | ||
run: | | ||
echo "You introduced some schema migration, please introduce the schema.rb changes as well" | ||
exit 1 | ||
- name: Missing data schema changes | ||
if: (steps.changed-files-yaml.outputs.data_schema_migrations_added_files == 'true') && (steps.changed-files-yaml.outputs.linters_any_changed == 'false') && (steps.changed-files-yaml.outputs.data_schema_any_changed == 'false') | ||
run: | | ||
echo "You introduced some data migrations, please introduce the data_schema.rb changes as well" | ||
exit 1 |