]> git.openstreetmap.org Git - nominatim.git/blob - .github/actions/setup-postgresql/action.yml
Merge remote-tracking branch 'upstream/master'
[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
8 runs:
9     using: "composite"
10
11     steps:
12         - name: Remove existing PostgreSQL
13           run: |
14               sudo apt-get purge -yq postgresql*
15               sudo apt install curl ca-certificates gnupg
16               curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
17               sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
18               sudo apt-get update -qq
19
20           shell: bash
21
22         - name: Install PostgreSQL
23           run: |
24               sudo apt-get install -y -qq --no-install-suggests --no-install-recommends postgresql-client-${PGVER} postgresql-${PGVER}-postgis-3 postgresql-${PGVER}-postgis-3-scripts postgresql-contrib-${PGVER} postgresql-${PGVER}
25           shell: bash
26           env:
27               PGVER: ${{ inputs.postgresql-version }}
28
29         - name: Adapt postgresql configuration
30           run: |
31               echo 'fsync = off' | sudo tee /etc/postgresql/${PGVER}/main/conf.d/local.conf
32               echo 'synchronous_commit = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
33               echo 'full_page_writes = off' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
34               echo 'shared_buffers = 1GB' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
35               echo 'port = 5432' | sudo tee -a /etc/postgresql/${PGVER}/main/conf.d/local.conf
36           shell: bash
37           env:
38               PGVER: ${{ inputs.postgresql-version }}
39
40         - name: Setup database
41           run: |
42               sudo systemctl restart postgresql
43               sudo -u postgres createuser -S www-data
44               sudo -u postgres createuser -s runner
45           shell: bash