-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (55 loc) · 1.81 KB
/
codegen.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
60
61
62
63
64
65
66
67
68
69
name: CodeGen
on:
schedule:
- cron: 0 3 * * MON
workflow_dispatch:
jobs:
codegen:
name: CodeGen
runs-on: ubuntu-latest
env:
branchName: actions/codegen/${{ github.run_id }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@v4
- name: Setup Git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Run codegen
run: npx nx run-many --target codegen
- name: Make a new branch
run: git checkout -b ${{ env.branchName }}
- id: stage
name: Stage generated files
continue-on-error: true
run: git add *.generated.*
- name: Commit
if: steps.stage.outcome == 'success'
run: git commit -m "Update generated files"
- name: Push
if: steps.stage.outcome == 'success'
run: git push --set-upstream origin ${{ env.branchName }}
- name: Create Pull Request
if: steps.stage.outcome == 'success'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT }}
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'Update generated files',
owner,
repo,
head: '${{ env.branchName }}',
base: 'main',
body: [
'This PR is auto-generated by [a GitHub Action](https://github.com/git-filesystem/git-filesystem.js/blob/main/.github/workflows/codegen.yml)'
].join('\n')
});