-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (47 loc) · 1.39 KB
/
generate-migrations.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Generate migrations
on:
push:
branches:
- main
paths:
- apps/api/db/schema.ts
workflow_dispatch:
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 db:generate
- name: Commit changes
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
GIT_BRANCH="migrations-$(date +%s)"
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
git checkout -b $GIT_BRANCH
git add -f apps/api/db/migrations
git commit -m "Generate migrations"
git push origin $GIT_BRANCH
- 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',
})