42 lines
1.3 KiB
YAML
42 lines
1.3 KiB
YAML
name: Database Setup Automation
|
|
|
|
on:
|
|
# Trigger the workflow manually from the Gitea UI
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
create_db_and_user:
|
|
# Use a standard Linux runner environment
|
|
runs-on: ubuntu-latest
|
|
|
|
# NOTE: The job will run inside a Docker image with the psql client.
|
|
container:
|
|
image: postgres:15-alpine
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure and Create PostgreSQL Resources
|
|
# Set environment variables from the Gitea Secrets
|
|
env:
|
|
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
|
|
POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }}
|
|
POSTGRES_ADMIN_USER: ${{ secrets.POSTGRES_ADMIN_USER }}
|
|
POSTGRES_ADMIN_PASSWORD: ${{ secrets.POSTGRES_ADMIN_PASSWORD }}
|
|
NEW_DB_NAME: ${{ secrets.NEW_DB_NAME }}
|
|
NEW_DB_USER: ${{ secrets.NEW_DB_USER }}
|
|
NEW_DB_PASSWORD: ${{ secrets.NEW_DB_PASSWORD }}
|
|
|
|
run: |
|
|
echo "Running database creation script..."
|
|
|
|
# Export the admin password so psql can use it automatically
|
|
export PGPASSWORD=$POSTGRES_ADMIN_PASSWORD
|
|
|
|
# Execute the script
|
|
./scripts/create_db_user.sh
|
|
|
|
# Unset the password variable for security
|
|
unset PGPASSWORD
|