1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- name: migrations
- on: pull_request
- jobs:
- did-migration-change:
- name: check if any migration changes
- runs-on: ubuntu-20.04
- timeout-minutes: 3
- # Map a step output to a job output
- outputs:
- added: ${{ steps.changes.outputs.migrations_added }}
- modified: ${{ steps.changes.outputs.migrations_modified }}
- steps:
- - name: Checkout sentry
- uses: actions/checkout@v2
- - name: Match migration files
- uses: getsentry/paths-filter@v2
- id: changes
- with:
- token: ${{ github.token }}
- filters: .github/file-filters.yml
- modified-migration:
- name: check if modified migration
- runs-on: ubuntu-20.04
- timeout-minutes: 4
- needs: did-migration-change
- if: ${{ needs.did-migration-change.outputs.modified == 'true' }}
- steps:
- - name: Failure because of modified migration
- shell: bash
- run: |
- echo "If you have a valid reason to modify a migration please get approval"
- echo "from @getsentry/owners-migrations, then ask a Github admin to merge." && exit 1
- sql:
- name: Generate SQL
- runs-on: ubuntu-20.04
- timeout-minutes: 8
- needs: did-migration-change
- if: ${{ needs.did-migration-change.outputs.added == 'true' }}
- steps:
- # Checkout master to run all merged migrations.
- - uses: actions/checkout@v1
- with:
- ref: master
- - name: Set python version output
- id: python-version
- run: |
- echo "::set-output name=python-version::$(cat .python-version)"
- # Until GH composite actions can use `uses`, we need to setup python here
- - uses: actions/setup-python@v2
- with:
- python-version: ${{ steps.python-version.outputs.python-version }}
- - name: Setup pip
- uses: ./.github/actions/setup-pip
- id: pip
- - name: pip cache
- uses: actions/cache@v2
- with:
- path: ${{ steps.pip.outputs.pip-cache-dir }}
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Setup sentry env
- uses: ./.github/actions/setup-sentry
- id: setup
- - name: Apply migrations
- run: |
- sentry upgrade --noinput
- # Checkout the current ref
- - uses: actions/checkout@v1
- with:
- clean: false
- - name: Get changed migration files
- id: file
- run: |
- echo $(git diff --diff-filter=A --name-only origin/master HEAD)
- echo "::set-output name=added::$(git diff --diff-filter=A --name-only origin/master HEAD | grep 'src/sentry/migrations/')"
- - name: Generate SQL for migration
- uses: getsentry/action-migrations@v1.0.7
- env:
- SENTRY_LOG_LEVEL: ERROR
- with:
- githubToken: ${{ secrets.GITHUB_TOKEN }}
- migration: ${{ steps.file.outputs.added }}
|