ci: streamline pipeline and add dev deploy actions
Some checks failed
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (pull_request) Has been skipped
CI/CD Pipeline / Quality Gate (pull_request) Failing after 2m47s
CI/CD Pipeline / Build and Push Images (pull_request) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 3m14s
CI/CD Pipeline / Build and Push Images (push) Has been skipped
CI/CD Pipeline / Internal Notify (pull_request) Successful in 1s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
Some checks failed
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (pull_request) Has been skipped
CI/CD Pipeline / Quality Gate (pull_request) Failing after 2m47s
CI/CD Pipeline / Build and Push Images (pull_request) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 3m14s
CI/CD Pipeline / Build and Push Images (push) Has been skipped
CI/CD Pipeline / Internal Notify (pull_request) Successful in 1s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
This commit is contained in:
77
.gitea/workflows/dev-db-maintenance.yml
Normal file
77
.gitea/workflows/dev-db-maintenance.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
name: Dev Database Maintenance
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
confirm:
|
||||
description: "Type CLEAN_DEV_DB to drop and recreate the dev public schema"
|
||||
required: true
|
||||
default: ""
|
||||
|
||||
env:
|
||||
POSTGRES_HOST: "10.10.0.114"
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DB: "mostovik"
|
||||
POSTGRES_USER: "postgres"
|
||||
POSTGRES_PASSWORD: "postgres"
|
||||
|
||||
jobs:
|
||||
cleanup_dev_database:
|
||||
name: Cleanup Dev Database
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
if: ${{ github.ref == 'refs/heads/dev' }}
|
||||
|
||||
steps:
|
||||
- name: Validate confirmation
|
||||
env:
|
||||
CONFIRM: ${{ github.event.inputs.confirm }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "${CONFIRM}" != "CLEAN_DEV_DB" ]; then
|
||||
echo "Manual confirmation must be exactly CLEAN_DEV_DB" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install PostgreSQL client
|
||||
run: |
|
||||
set -euo pipefail
|
||||
APT_RUNNER=()
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
APT_RUNNER=(sudo)
|
||||
fi
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
"${APT_RUNNER[@]}" apt-get update
|
||||
"${APT_RUNNER[@]}" apt-get install -y postgresql-client
|
||||
|
||||
- name: Drop and recreate public schema
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
|
||||
psql \
|
||||
--set ON_ERROR_STOP=1 \
|
||||
--host="${POSTGRES_HOST}" \
|
||||
--port="${POSTGRES_PORT}" \
|
||||
--username="${POSTGRES_USER}" \
|
||||
--dbname="${POSTGRES_DB}" \
|
||||
<<'SQL'
|
||||
SELECT pg_terminate_backend(pid)
|
||||
FROM pg_stat_activity
|
||||
WHERE datname = current_database()
|
||||
AND pid <> pg_backend_pid();
|
||||
|
||||
DROP SCHEMA IF EXISTS public CASCADE;
|
||||
CREATE SCHEMA public;
|
||||
GRANT ALL ON SCHEMA public TO postgres;
|
||||
GRANT ALL ON SCHEMA public TO public;
|
||||
SQL
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
set -euo pipefail
|
||||
{
|
||||
echo "Dev database cleanup completed."
|
||||
echo "Database: ${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
|
||||
} >> "${GITHUB_STEP_SUMMARY:-/dev/stdout}"
|
||||
Reference in New Issue
Block a user