Skip to content

CodeGen

CodeGen #137

Workflow file for this run

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')
});