-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
93 lines (79 loc) · 2.86 KB
/
migrations.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: migrations
on: pull_request
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
# the default default is:
# bash --noprofile --norc -eo pipefail {0}
shell: bash --noprofile --norc -eo pipefail -ux {0}
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@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Match migration files
uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
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
run: |
echo "If you have a valid reason to modify a migration please get approval"
echo "from @getsentry/owners-migrations." && exit 1
sql:
name: Generate SQL
runs-on: ubuntu-20.04
timeout-minutes: 8
strategy:
matrix:
pg-version: ['14']
needs: did-migration-change
if: needs.did-migration-change.outputs.added == 'true'
steps:
# Checkout master to run all merged migrations.
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
ref: master
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
with:
pg-version: ${{ matrix.pg-version }}
- name: Apply migrations
run: |
sentry upgrade --noinput
# Checkout the current ref
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
clean: false
- name: Get changed migration files
id: file
run: |
echo 'added<<EOF' >> "$GITHUB_OUTPUT"
git diff --diff-filter=A --name-only origin/master HEAD -- 'src/sentry/*/migrations/' 'src/sentry/migrations/' >> "$GITHUB_OUTPUT"
echo 'EOF' >> "$GITHUB_OUTPUT"
- name: Generate SQL for migration
uses: getsentry/action-migrations@4d8ed0388dfc0774302bbfd5204e518f9ac4f066 # main
env:
SENTRY_LOG_LEVEL: ERROR
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
migration: ${{ steps.file.outputs.added }}