mirror of
https://github.com/beilunyang/moemail.git
synced 2025-12-24 11:30:51 +08:00
refactor: Update database migration scripts and enhance CI workflow
This commit is contained in:
24
.github/workflows/deploy.yml
vendored
24
.github/workflows/deploy.yml
vendored
@@ -33,6 +33,22 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
# Check if database migrations have changes
|
||||
- name: Check migrations changes
|
||||
id: check_migrations
|
||||
run: |
|
||||
# If this is the first tag, we need to run migrations
|
||||
if [ -z "${{ steps.previoustag.outputs.tag }}" ]; then
|
||||
echo "migrations_changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
# Check if any files in drizzle directory have changed
|
||||
if git diff ${{ steps.previoustag.outputs.tag }}..HEAD --name-only | grep -q "^drizzle/"; then
|
||||
echo "migrations_changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "migrations_changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
fi
|
||||
|
||||
# Process configuration files
|
||||
- name: Process configuration files
|
||||
run: |
|
||||
@@ -57,6 +73,14 @@ jobs:
|
||||
sed -i "s/database_id = \".*\"/database_id = \"${{ secrets.DATABASE_ID }}\"/" wrangler.cleanup.toml
|
||||
fi
|
||||
|
||||
# Run database migrations if needed
|
||||
- name: Run database migrations
|
||||
if: steps.check_migrations.outputs.migrations_changed == 'true'
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
run: pnpm db:migrate-remote
|
||||
|
||||
# Check if workers have changes
|
||||
- name: Check workers changes
|
||||
id: check_changes
|
||||
|
||||
Reference in New Issue
Block a user