Skip to content

Use db user when adding tables to replication #468

Use db user when adding tables to replication

Use db user when adding tables to replication #468

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- "v**"
pull_request:
concurrency:
group: branch-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
rspec:
runs-on: ubuntu-20.04
timeout-minutes: 30
name: Ruby ${{ matrix.ruby }} - PG ${{ matrix.pg.from }} -> PG ${{ matrix.pg.to }}
strategy:
matrix:
ruby: ["3.0.5", "3.1.4", "3.2.1"]
pg:
[
{ from: 10, to: 11 },
{ from: 11, to: 12 },
{ from: 12, to: 13 },
{ from: 13, to: 14 },
{ from: 14, to: 15 },
{ from: 10, to: 15 },
]
steps:
- uses: actions/checkout@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Bundle install
env:
RAILS_ENV: test
run: |
gem install bundler
bundle install --jobs 4 --retry 3 --path vendor/bundle
- name: Run Lint
run: bundle exec rubocop
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: "Setug PG databases"
run: |
set -euvxo pipefail
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-${{ matrix.pg.from }} postgresql-client-${{ matrix.pg.from }}
sudo apt-get install --yes --no-install-recommends postgresql-${{ matrix.pg.to }} postgresql-client-${{ matrix.pg.to }}
sudo systemctl restart postgresql@${{ matrix.pg.from }}-main.service
sudo systemctl restart postgresql@${{ matrix.pg.to }}-main.service
sudo systemctl restart postgresql
# Escape the quote because we are setting the password in PG
# String: james-bond123@7!''3aaR
export PGPASSWORD='james-bond123@7!'"'"''"'"'3aaR'
sudo su - postgres -c "createuser -p 5432 -d -s -e -l james-bond"
sudo -u postgres psql -p 5432 -c 'alter user "james-bond" with encrypted password '"'"''"$PGPASSWORD"''"'"';'
sudo su - postgres -c "createdb -p 5432 postgres-db"
sudo -u postgres psql -p 5432 -c "grant all privileges on database \"postgres-db\" to \"james-bond\";"
sudo su - postgres -c "createuser -p 5433 -d -s -e -l james-bond"
sudo -u postgres psql -p 5433 -c 'alter user "james-bond" with encrypted password '"'"''"$PGPASSWORD"''"'"';'
sudo su - postgres -c "createdb -p 5433 postgres-db"
sudo -u postgres psql -p 5433 -c "grant all privileges on database \"postgres-db\" to \"james-bond\";"
# Remove the escaped quote since we are passing the pwd to psql
# String: james-bond123@7!'3aaR
export PGPASSWORD='james-bond123@7!'"'"'3aaR'
psql -h localhost -d postgres-db -U james-bond -p 5432 -c 'ALTER SYSTEM SET wal_level = logical;'
psql -h localhost -d postgres-db -U james-bond -p 5433 -c 'ALTER SYSTEM SET wal_level = logical;'
sudo systemctl restart postgresql@${{ matrix.pg.from }}-main.service
sudo systemctl restart postgresql@${{ matrix.pg.to }}-main.service
sudo systemctl restart postgresql
psql -h localhost -d postgres-db -U james-bond -p 5432 -c 'show wal_level;'
psql -h localhost -d postgres-db -U james-bond -p 5433 -c 'show wal_level;'
- name: Run RSpec
run: bundle exec rspec
build-push-image:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-20.04
timeout-minutes: 30
needs: [rspec]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Branch name
id: version_name
run: |
echo ::set-output name=no_v_tag::${GITHUB_REF_NAME:1}
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: VERSION=${{ steps.version_name.outputs.no_v_tag }}
tags: shayonj/pg_easy_replicate:latest, shayonj/pg_easy_replicate:${{ steps.version_name.outputs.no_v_tag }}