storage/.forgejo/workflows/deploy.yaml
Sergei Poljanski b6bcc9f882
All checks were successful
Deploy storage stack / deploy (push) Successful in 19s
Provision read-only credentials for datacenterbingo
The public bingo site is moving out of the asxpio container and only
needs to read the bingo tables and the bingo/ photos. Give it a role
limited to SELECT on those two tables (with read-only transactions by
default) and a MinIO user limited to GetObject under
asxpio-invoices/bingo/, instead of reusing asxpio's read-write
credentials.

Both steps are skipped while the BINGO_* secrets are unset, so this
deploys safely before they exist. Tables missing on a fresh install
are granted on the next deploy.

Assisted-by: Claude:opus-5
2026-10-12 03:47:57 +04:00

71 lines
2.8 KiB
YAML

name: Deploy storage stack
on:
push:
branches:
- main
jobs:
deploy:
runs-on: arch-latest
steps:
- name: Install dependencies
run: |
pacman -Syu --noconfirm nodejs openssh rsync
- name: Checkout code
uses: actions/checkout@v4
- name: Copy compose + init scripts
uses: easingthemes/ssh-deploy@v5.1.0
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
REMOTE_HOST: ${{ secrets.DEPLOY_IP }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "docker-compose.yml init"
TARGET: "/opt/storage/"
- name: Write .env from secrets and bring stack up
uses: appleboy/ssh-action@v1.2.3
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
ASXPIO_DB_PASSWORD: ${{ secrets.ASXPIO_DB_PASSWORD }}
ASXPIO_S3_ACCESS_KEY: ${{ secrets.ASXPIO_S3_ACCESS_KEY }}
ASXPIO_S3_SECRET_KEY: ${{ secrets.ASXPIO_S3_SECRET_KEY }}
BINGO_DB_PASSWORD: ${{ secrets.BINGO_DB_PASSWORD }}
BINGO_S3_ACCESS_KEY: ${{ secrets.BINGO_S3_ACCESS_KEY }}
BINGO_S3_SECRET_KEY: ${{ secrets.BINGO_S3_SECRET_KEY }}
with:
host: ${{ secrets.DEPLOY_IP }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
envs: POSTGRES_PASSWORD,MINIO_ROOT_USER,MINIO_ROOT_PASSWORD,ASXPIO_DB_PASSWORD,ASXPIO_S3_ACCESS_KEY,ASXPIO_S3_SECRET_KEY,BINGO_DB_PASSWORD,BINGO_S3_ACCESS_KEY,BINGO_S3_SECRET_KEY
script_stop: true
script: |
umask 077
mkdir -p /opt/storage
cat > /opt/storage/.env <<EOF
POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
MINIO_ROOT_USER=${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
ASXPIO_DB_PASSWORD=${ASXPIO_DB_PASSWORD}
ASXPIO_S3_ACCESS_KEY=${ASXPIO_S3_ACCESS_KEY}
ASXPIO_S3_SECRET_KEY=${ASXPIO_S3_SECRET_KEY}
BINGO_DB_PASSWORD=${BINGO_DB_PASSWORD}
BINGO_S3_ACCESS_KEY=${BINGO_S3_ACCESS_KEY}
BINGO_S3_SECRET_KEY=${BINGO_S3_SECRET_KEY}
EOF
chmod 600 /opt/storage/.env
chmod +x /opt/storage/init/postgres-init.sh /opt/storage/init/minio-bootstrap.sh
cd /opt/storage
docker compose pull
docker compose up -d postgres minio
# Run init containers (idempotent) and wait for them to exit.
docker compose up --exit-code-from postgres-init postgres-init
docker compose up --exit-code-from minio-init minio-init
echo "Storage stack deployed."