-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (57 loc) · 1.68 KB
/
sql.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
name: SQL
permissions:
contents: read
checks: write
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
migrations:
name: migrations
runs-on: ubuntu-latest
env:
POSTGRES_DB: sport_log
POSTGRES_PASSWORD: test-passwd
POSTGRES_USER: sport_admin
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: sport_log
POSTGRES_PASSWORD: test-passwd
POSTGRES_USER: sport_admin
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@stable
- name: load cache
uses: Swatinem/rust-cache@v2
- name: install postgresql
run: |
sudo apt-get update -y
sudo apt-get install libpq-dev postgresql-client-common postgresql
- name: install diesel_cli
run: cargo install diesel_cli --no-default-features --features postgres
- name: create .env file
working-directory: sport-log-types
run: echo "DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost/$POSTGRES_DB" > .env
- name: setup database
working-directory: sport-log-types
run: diesel database setup # --locked-schema # TODO
- name: revert migrations
working-directory: sport-log-types
run: diesel migration revert --all
- name: run migrations
working-directory: sport-log-types
run: diesel migration run