Skip to content

Commit

Permalink
Merge pull request #106 from dump-hr/migrations-ci
Browse files Browse the repository at this point in the history
migrations ci - generate PR
  • Loading branch information
bdeak4 authored Jan 14, 2024
2 parents c51aaf0 + 418308d commit 36a4604
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
55 changes: 18 additions & 37 deletions .github/workflows/generate-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
paths:
- 'apps/api/db/schema.ts'

jobs:
generate_migrations:
Expand Down Expand Up @@ -35,42 +37,21 @@ jobs:
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_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
git add -f apps/api/db/migrations
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',
# })
- uses: actions/github-script@v6
with:
script: |
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: process.env.GIT_BRANCH,
base: 'main',
title: 'Generate migrations',
})
2 changes: 2 additions & 0 deletions apps/api/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,5 @@ export const notification = pgTable('notification', {
isActive: boolean('is_active').default(false),
activatedAt: timestamp('activated_at', { mode: 'string' }),
});

// trigger

0 comments on commit 36a4604

Please sign in to comment.