migrations.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: migrations
  2. on:
  3. pull_request:
  4. paths:
  5. - 'src/sentry/migrations/*'
  6. jobs:
  7. sql:
  8. name: Generate SQL
  9. runs-on: ubuntu-16.04
  10. timeout-minutes: 8
  11. steps:
  12. # Checkout master to run all merged migrations.
  13. - uses: actions/checkout@v1
  14. with:
  15. ref: master
  16. # Until GH composite actions can use `uses`, we need to setup python here
  17. - uses: actions/setup-python@v2
  18. with:
  19. python-version: 2.7.17
  20. - name: Setup pip
  21. uses: ./.github/actions/setup-pip
  22. id: pip
  23. - name: pip cache
  24. uses: actions/cache@v2
  25. with:
  26. path: ${{ steps.pip.outputs.pip-cache-dir }}
  27. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  28. restore-keys: |
  29. ${{ runner.os }}-pip-
  30. - name: Setup sentry env
  31. uses: ./.github/actions/setup-sentry
  32. id: setup
  33. with:
  34. python: 2
  35. - name: Apply migrations
  36. run: |
  37. sentry upgrade --noinput
  38. # Checkout the current ref
  39. - uses: actions/checkout@v1
  40. with:
  41. clean: false
  42. - name: Get changed migration files
  43. id: file
  44. run: |
  45. echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
  46. echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  47. - name: Generate SQL for migration
  48. uses: getsentry/action-migrations@v1.0.7
  49. env:
  50. SENTRY_LOG_LEVEL: ERROR
  51. with:
  52. githubToken: ${{ secrets.GITHUB_TOKEN }}
  53. migration: ${{ steps.file.outputs.modified }}