migrations.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. - name: Set python version output
  17. id: python-version
  18. run: |
  19. echo "::set-output name=python-version::$(cat .python-version)"
  20. # Until GH composite actions can use `uses`, we need to setup python here
  21. - uses: actions/setup-python@v2
  22. with:
  23. python-version: ${{ steps.python-version.outputs.python-version }}
  24. - name: Setup pip
  25. uses: ./.github/actions/setup-pip
  26. id: pip
  27. - name: pip cache
  28. uses: actions/cache@v2
  29. with:
  30. path: ${{ steps.pip.outputs.pip-cache-dir }}
  31. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  32. restore-keys: |
  33. ${{ runner.os }}-pip-
  34. - name: Setup sentry env
  35. uses: ./.github/actions/setup-sentry
  36. id: setup
  37. - name: Apply migrations
  38. run: |
  39. sentry upgrade --noinput
  40. # Checkout the current ref
  41. - uses: actions/checkout@v1
  42. with:
  43. clean: false
  44. - name: Get changed migration files
  45. id: file
  46. run: |
  47. echo $(git diff --diff-filter=AM --name-only origin/master HEAD)
  48. echo "::set-output name=modified::$(git diff --diff-filter=AM --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
  49. - name: Generate SQL for migration
  50. uses: getsentry/action-migrations@v1.0.7
  51. env:
  52. SENTRY_LOG_LEVEL: ERROR
  53. with:
  54. githubToken: ${{ secrets.GITHUB_TOKEN }}
  55. migration: ${{ steps.file.outputs.modified }}