|
| 1 | +name: Update Locale |
| 2 | + |
| 3 | +# This action runs: |
| 4 | +# - When this file changes |
| 5 | +# - When changes on documentation (doc) |
| 6 | +# - When is triggered manually |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + push: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + update-locale: |
| 17 | + name: Update Locale |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - name: Get postgres version |
| 30 | + run: | |
| 31 | + sudo service postgresql start |
| 32 | + pgver=$(psql --version | grep -Po '(?<=psql \(PostgreSQL\) )[^;]+(?=\.\d+ \()') |
| 33 | + echo "PGVER=${pgver}" >> $GITHUB_ENV |
| 34 | + echo "PGIS=3" >> $GITHUB_ENV |
| 35 | +
|
| 36 | + - name: Extract branch name and commit hash |
| 37 | + run: | |
| 38 | + branch=${GITHUB_REF#refs/heads/} |
| 39 | + git_hash=$(git rev-parse --short "$GITHUB_SHA") |
| 40 | + echo "GIT_HASH=$git_hash" >> $GITHUB_ENV |
| 41 | +
|
| 42 | + - name: Add PostgreSQL APT repository |
| 43 | + run: | |
| 44 | + sudo apt-get install curl ca-certificates gnupg |
| 45 | + curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
| 46 | + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ \ |
| 47 | + $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
| 48 | +
|
| 49 | + - name: Install python |
| 50 | + uses: actions/setup-python@v5 |
| 51 | + with: |
| 52 | + python-version: '3.x' |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + sudo apt-get update |
| 57 | + sudo apt-get install -y osm2pgrouting \ |
| 58 | + postgresql-${PGVER}-postgis-${PGIS} \ |
| 59 | + postgresql-${PGVER}-postgis-${PGIS}-scripts \ |
| 60 | + postgresql-${PGVER}-pgrouting |
| 61 | +
|
| 62 | + python -m pip install --upgrade pip |
| 63 | + pip install -r REQUIREMENTS.txt |
| 64 | + pip list |
| 65 | +
|
| 66 | + - name: Configure |
| 67 | + run: | |
| 68 | + service postgresql status |
| 69 | + sudo service postgresql start |
| 70 | + service postgresql status |
| 71 | + sudo -u postgres createdb -p ${POSTGRES_PORT} setup |
| 72 | + sudo -u postgres psql -c 'CREATE ROLE "runner" SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN PASSWORD $$runner$$;' -d setup |
| 73 | + echo :5432:*:runner:runner >> .pgpass |
| 74 | + sudo -u postgres psql -c 'CREATE ROLE "user" SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN PASSWORD $$user$$;' -d setup |
| 75 | + echo :5432:*:user:user >> .pgpass |
| 76 | + mkdir build |
| 77 | + cd build |
| 78 | + cmake -DLOCALE=ON .. |
| 79 | + env: |
| 80 | + POSTGRES_HOST: localhost |
| 81 | + POSTGRES_PORT: 5432 |
| 82 | + POSTGRES_USER: postgres |
| 83 | + POSTGRES_PASSWORD: postgres |
| 84 | + POSTGRES_DB: setup |
| 85 | + |
| 86 | + - name: Initialize mandatory git config |
| 87 | + run: | |
| 88 | + git config user.name "github-actions[bot]" |
| 89 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 90 | +
|
| 91 | + - name: Update locale |
| 92 | + run: | |
| 93 | + bash .github/scripts/update_locale.sh |
| 94 | +
|
| 95 | + # Add the files, commit and push |
| 96 | + git diff --staged --quiet || git commit -m "Update locale: commit ${{ env.GIT_HASH }}" |
| 97 | + git restore . # Remove the unstaged changes before rebasing |
| 98 | + git push |
0 commit comments