Skip to content

Commit

Permalink
Merge pull request #105 from dump-hr/migrations-ci
Browse files Browse the repository at this point in the history
Migrations CI
  • Loading branch information
bdeak4 authored Jan 14, 2024
2 parents 5470d8f + 8a4a3b1 commit c51aaf0
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 964 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: yarn install --immutable

- name: Build frontend web apps
run: yarn turbo run build --filter=admin... --filter=sponsor...
run: yarn build --filter=admin... --filter=sponsor...

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/generate-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Generate migrations

on:
push:
branches:
- main

jobs:
generate_migrations:
name: Generate migrations
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable

- name: Generate migrations
run: yarn generate

- name: Commit changes
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add -f apps/api/db/migrations
if ! git diff --staged --quiet apps/api/db/migrations; then
git commit -m "Generate migrations"
git push
fi
# - name: Git add
# continue-on-error: true
# id: has-migrations
# run: |
# git add -f apps/api/db/migrations
# git diff --staged --quiet apps/api/db/migrations && exit 1 || exit 0

# - name: Git commit and push
# if: ${{ steps.has-migrations.conclusion == 'success' }}
# env:
# GIT_USER: ${{ github.actor }}
# run: |
# git config --global user.name "$GIT_USER"
# git config --global user.email "[email protected]"

# GIT_BRANCH="migrations-$(date +%s)"
# echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
# git checkout -b $GIT_BRANCH

# git commit -m "Generate migrations"
# git push origin $GIT_BRANCH

# - uses: actions/github-script@v6
# if: ${{ steps.has-migrations.conclusion == 'success' }}
# with:
# script: |
# github.rest.pulls.create({
# owner: context.repo.owner,
# repo: context.repo.repo,
# head: process.env.GIT_BRANCH,
# base: 'main',
# title: 'Generate migrations',
# })
3 changes: 3 additions & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ lerna-debug.log*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json


db/migrations/*
Empty file added apps/api/db/migrations/.gitkeep
Empty file.
191 changes: 0 additions & 191 deletions apps/api/db/migrations/0000_green_turbo.sql

This file was deleted.

Loading

0 comments on commit c51aaf0

Please sign in to comment.