Skip to content

Commit c5980a1

Browse files
committed
For PRs, get SHA from base
1 parent 0a8c24f commit c5980a1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/migration-test.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
SECRET_BASE_KEY: test_key
1919
RAILS_ENV: test
2020
REDIS_TEST_URL: redis://localhost:6379/0
21+
PREV_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
22+
2123
services:
2224
postgres:
2325
image: postgres
@@ -59,17 +61,17 @@ jobs:
5961
cp config/ingestion.example.yml config/ingestion.yml
6062
- name: Checkout previous schema
6163
# Checks out previous schema.rb and temporarily renames migrations
62-
if: github.event.before != '0000000000000000000000000000000000000000'
64+
if: env.PREV_SHA != '0000000000000000000000000000000000000000'
6365
run: |
64-
git fetch origin ${{ github.event.before }}
65-
git checkout ${{ github.event.before }} -- db/schema.rb
66+
git fetch origin ${{ env.PREV_SHA }}
67+
git checkout ${{ env.PREV_SHA }} -- db/schema.rb
6668
mv db/migrate db/migrate.bkp
67-
git checkout ${{ github.event.before }} -- db/migrate
69+
git checkout ${{ env.PREV_SHA }} -- db/migrate
6870
- name: Load previous database schema
6971
run: bundle exec rake db:test:prepare
7072
- name: Restore migrations
7173
# Restore the renamed migrations
72-
if: github.event.before != '0000000000000000000000000000000000000000'
74+
if: env.PREV_SHA != '0000000000000000000000000000000000000000'
7375
run: |
7476
rm -rf db/migrate
7577
mv db/migrate.bkp db/migrate

0 commit comments

Comments
 (0)