]> git.openstreetmap.org Git - nominatim.git/blob - .github/actions/setup-postgresql/action.yml
060a678941b2610c5bfc29c4bada275812a7ccd3
[nominatim.git] / .github / actions / setup-postgresql / action.yml
1 name: 'Setup Postgresql and Postgis'
2
3 inputs:
4     postgresql-version:
5         description: 'Version of PostgreSQL to install'
6         required: true
7     postgis-version:
8         description: 'Version of Postgis to install'
9         required: true
10
11 runs:
12     using: "composite"
13
14     steps:
15         - name: Remove existing PostgreSQL
16           run: |
17               sudo apt-get purge -yq postgresql*
18               sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
19               sudo apt-get update -qq
20
21           shell: bash
22
23         - name: Install PostgreSQL
24           run: |
25               sudo apt-get install -y -qq --no-install-suggests --no-install-recommends postgresql-client-${PGVER} postgresql-${PGVER}-postgis-${POSTGISVER} postgresql-${PGVER}-postgis-${POSTGISVER}-scripts postgresql-contrib-${PGVER} postgresql-${PGVER} postgresql-server-dev-${PGVER}
26           shell: bash
27           env:
28               PGVER: ${{ inputs.postgresql-version }}
29               POSTGISVER: ${{ inputs.postgis-version }}
30
31         - name: Adapt postgresql configuration
32           run: |
33               echo 'fsync = off' | sudo tee /etc/postgresql/${PGVER}/main/conf.d/local.conf
34               echo 'synchronous_commit = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
35               echo 'full_page_writes = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
36               echo 'shared_buffers = 1GB' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
37               echo 'port = 5432' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
38           shell: bash
39           env:
40               PGVER: ${{ inputs.postgresql-version }}
41
42         - name: Setup database
43           run: |
44               sudo systemctl restart postgresql
45               sudo -u postgres createuser -S www-data
46               sudo -u postgres createuser -s runner
47           shell: bash