-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
101 lines (94 loc) · 3.08 KB
/
action.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
94
95
96
97
98
99
100
101
name: "Set up test db"
description: "Set up test db"
inputs:
db_user:
description: DB user
required: false
default: postgres
db_password:
description: DB password
required: false
default: postgres
db_name:
description: DB user
required: false
default: postgres_test
db_port:
description: DB port
required: false
default: "5432"
db_extensions:
description: DB extensions list separated by a space
required: false
default: pg_stat_statements pgcrypto
db_schemas:
description: DB schemas list to create separated by a space
required: false
db_migrations_path:
description: DB migrations path
required: false
default: db/migrations
db_migrations_config_path:
description: DB migrations config path
required: false
default: db/test/conf/flyway.conf
migrate_from_be_clientes_ar:
description: Migrate from be-clientes-ar
required: false
default: "false"
github_token:
description: GitHub token
required: false
runs:
using: "composite"
steps:
- name: Setup redis
uses: supercharge/redis-github-action@1.7.0
with:
redis-version: 7
redis-password: "admin"
- name: Setup Postgres database
uses: Daniel-Marynicz/postgresql-action@master
with:
postgres_image_tag: 13.10
postgres_user: "${{ inputs.db_user }}"
postgres_password: "${{ inputs.db_password }}"
postgres_db: "${{ inputs.db_name }}"
postgres_extensions: "${{ inputs.db_extensions }}"
- name: Install psql
shell: bash
id: install-psql
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
- name: Create schema
shell: bash
id: create-schemas
if: inputs.db_schemas != ''
run: |
IFS=' ' read -r -a schemas <<< "${{ inputs.db_schemas }}"
connection_string="postgres://${{ inputs.db_user }}:${{ inputs.db_password }}@localhost:${{ inputs.db_port }}/${{ inputs.db_name }}"
do for schema in "${schemas[@]}"
psql -d $connection_string -c "CREATE SCHEMA IF NOT EXISTS $schema;"
done
- name: Install flyway
shell: bash
id: install-flyway
run: wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.7.2/flyway-commandline-10.7.2-linux-x64.tar.gz | tar xvz && sudo ln -s `pwd`/flyway-10.7.2/flyway /usr/local/bin
- name: Copy migrations from be-clientes-ar
uses: actions/checkout@v4
if: inputs.migrate_from_be_clientes_ar == 'true'
with:
repository: "heyatlas/api-graphql"
ref: "master"
token: ${{ inputs.github_token }}
path: api-graphql
- name: Make local migrations
shell: bash
id: make-migrations
run: |
flyway migrate -url=jdbc:postgresql://localhost:${{ inputs.db_port }}/${{ inputs.db_name }} \
-user=${{ inputs.db_user }} \
-password=${{ inputs.db_password }} \
-locations=${{ inputs.db_migrations_path }} \
-configFiles=${{ inputs.db_migrations_config_path }}