migrations.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: migrations
  2. on: pull_request
  3. jobs:
  4. did-migration-change:
  5. name: check if any migration changes
  6. runs-on: ubuntu-20.04
  7. timeout-minutes: 3
  8. # Map a step output to a job output
  9. outputs:
  10. added: ${{ steps.changes.outputs.migrations_added }}
  11. modified: ${{ steps.changes.outputs.migrations_modified }}
  12. steps:
  13. - name: Checkout sentry
  14. uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
  15. - name: Match migration files
  16. uses: getsentry/paths-filter@66f7f1844185eb7fb6738ea4ea59d74bb99199e5 # v2
  17. id: changes
  18. with:
  19. token: ${{ github.token }}
  20. filters: .github/file-filters.yml
  21. modified-migration:
  22. name: check if modified migration
  23. runs-on: ubuntu-20.04
  24. timeout-minutes: 4
  25. needs: did-migration-change
  26. if: needs.did-migration-change.outputs.modified == 'true'
  27. steps:
  28. - name: Failure because of modified migration
  29. shell: bash
  30. run: |
  31. echo "If you have a valid reason to modify a migration please get approval"
  32. echo "from @getsentry/owners-migrations, then ask a Github admin to merge." && exit 1
  33. sql:
  34. name: Generate SQL
  35. runs-on: ubuntu-20.04
  36. timeout-minutes: 8
  37. strategy:
  38. matrix:
  39. pg-version: ['9.6']
  40. needs: did-migration-change
  41. if: needs.did-migration-change.outputs.added == 'true'
  42. steps:
  43. # Checkout master to run all merged migrations.
  44. - uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
  45. with:
  46. ref: master
  47. - name: Setup sentry env
  48. uses: ./.github/actions/setup-sentry
  49. id: setup
  50. with:
  51. pg-version: ${{ matrix.pg-version }}
  52. - name: Apply migrations
  53. run: |
  54. sentry upgrade --noinput
  55. # Checkout the current ref
  56. - uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1
  57. with:
  58. clean: false
  59. - name: Get changed migration files
  60. id: file
  61. run: |
  62. echo $(git diff --diff-filter=A --name-only origin/master HEAD)
  63. echo "::set-output name=added::$(git diff --diff-filter=A --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  64. - name: Generate SQL for migration
  65. uses: getsentry/action-migrations@f1dc34590460c0fe06ec11c00fec6c16a2159977 # main
  66. env:
  67. SENTRY_LOG_LEVEL: ERROR
  68. with:
  69. githubToken: ${{ secrets.GITHUB_TOKEN }}
  70. migration: ${{ steps.file.outputs.added }}