added default workflows

This commit is contained in:
2025-01-07 16:23:51 +03:00
parent 7dabe9f65c
commit aea2e1729e
4 changed files with 237 additions and 154 deletions

View File

@@ -0,0 +1,53 @@
name: Workflow for prisma migrations
on:
workflow_call:
inputs:
PROD_PRISMA_SECRET_DB_PATH:
required: true
type: string
description: Prisma db url secret path in vault for prod
DEV_PRISMA_SECRET_DB_PATH:
required: true
type: string
description: Prisma db url secret path in vault for dev
secrets:
VAULT_TOKEN:
required: true
jobs:
migration:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
- name: Install dependencies
run: npm install
- name: Export secrets for prisma
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "PRISMA_DB_SECRET_PATH=${{ inputs.PROD_PRISMA_SECRET_DB_PATH }}" >> $GITHUB_ENV
else
echo "PRISMA_DB_SECRET_PATH=${{ inputs.DEV_PRISMA_SECRET_DB_PATH }}" >> $GITHUB_ENV
fi
- name: Import prisma db url
uses: hashicorp/vault-action@v2
with:
url: https://vault.project-rent-dev.com
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
${{ env.PRISMA_DB_SECRET_PATH }} | PRISMA_DB_URL;
- name: Apply all pending migrations to the database
run: npx prisma migrate deploy
env:
DATABASE_URL: ${{ env.PRISMA_DB_URL }}