mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-26 13:07:33 +09:00
## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
124 lines
3.8 KiB
YAML
124 lines
3.8 KiB
YAML
name: Migrate
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "migrate"
|
|
- "main"
|
|
- "*.staging"
|
|
- "*.migrate"
|
|
|
|
# Pending if other migration from the same branch is running
|
|
concurrency: migrate-${{ github.ref_name }}
|
|
|
|
permissions:
|
|
contents: read # to fetch code (actions/checkout)
|
|
statuses: write # This is required for the GitHub Script createCommitStatus to work
|
|
|
|
jobs:
|
|
migrate:
|
|
# This workflow is triggered only on pushes to the `main`, `*.staging` or 'migrate' branches.
|
|
# For `*.staging` and `migrate` it specifically checks if the commit message starts with `::migrate::`,
|
|
# indicating a migration-related change.
|
|
#
|
|
# Example usage:
|
|
# Execute a commit with a migration flag using:
|
|
# git commit --allow-empty -m "::migrate::test description"
|
|
# Note:
|
|
# This setup is a temporary measure. The intention is to transition to a fully automated publish and release process via GitHub Actions in the future.
|
|
if: (github.ref_name == 'main') || ((github.ref_name == 'migrate' || endsWith(github.ref_name, '.migrate') || endsWith(github.ref_name, '.staging')) && startsWith(github.event.head_commit.message, '::migrate::'))
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment:
|
|
name: ${{ (startsWith(github.ref_name, 'release') && endsWith(github.ref_name, '.staging')) && 'postgres_production' || 'postgres_development' }}
|
|
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.sha }} # HEAD commit instead of merge commit
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: pnpm
|
|
|
|
- name: pnpm instal
|
|
run: pnpm install --ignore-scripts
|
|
|
|
- name: generate prisma
|
|
run: pnpm --filter=@webstudio-is/prisma-client generate
|
|
|
|
- name: execute migration
|
|
run: pnpm --filter '@webstudio-is/prisma-client' run migrations migrate
|
|
env:
|
|
DIRECT_URL: ${{ secrets.DIRECT_URL }}
|
|
|
|
# Execute db tests (runs after migrations, even if they fail)
|
|
db-tests:
|
|
# Always run tests to see failures on CI, but only after migrate job completes
|
|
if: always()
|
|
|
|
needs: [migrate]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment:
|
|
name: ${{ (startsWith(github.ref_name, 'release') && endsWith(github.ref_name, '.staging')) && 'postgres_production' || 'postgres_development' }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.sha }} # HEAD commit instead of merge commit
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- name: Run database tests
|
|
run: pnpm -r db-test
|
|
env:
|
|
DIRECT_URL: ${{ secrets.DIRECT_URL }}
|
|
|
|
# Prints pending migrations
|
|
pending:
|
|
if: always()
|
|
|
|
needs: [migrate]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment:
|
|
name: ${{ (startsWith(github.ref_name, 'release') && endsWith(github.ref_name, '.staging')) && 'postgres_production' || 'postgres_development' }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.sha }} # HEAD commit instead of merge commit
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: pnpm
|
|
|
|
- name: pnpm instal
|
|
run: pnpm install --ignore-scripts
|
|
|
|
- name: generate prisma
|
|
run: pnpm --filter=@webstudio-is/prisma-client generate
|
|
|
|
- name: get pending
|
|
id: pending
|
|
run: |
|
|
echo "value=$(pnpm --filter '@webstudio-is/prisma-client' run migrations pending-count | grep ::pending-count::)" >> $GITHUB_OUTPUT
|
|
env:
|
|
DIRECT_URL: ${{ secrets.DIRECT_URL }}
|
|
|
|
- uses: ./.github/actions/add-status
|
|
with:
|
|
title: "⭕ Pending Migrations"
|
|
description: ${{ steps.pending.outputs.value }}
|
|
url: "https://webstudio.is"
|