aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/pr.yml
blob: f5c64823287b306dc1000c8e2a13f6d23ce6454e (plain)
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
name: PR

on:
  pull_request:

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
  check-code-generation:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    name: 'Check Code Generation: node-18, ubuntu-latest'
    permissions:
      pull-requests: write
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Install pnpm
        uses: pnpm/[email protected]
        with:
          version: 7

      - name: Set node version to 18
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'pnpm'

      - name: Install deps
        run: pnpm install
        env:
          CYPRESS_INSTALL_BINARY: 0

      - name: Generate code
        id: generate
        run: |
          pnpm run generate:locales
          pnpm run generate:api-docs
          pnpm run build
          pnpm run test -u
        continue-on-error: true

      - name: Check diff
        id: diff
        run: |
          git add .
          git diff --cached --exit-code
        continue-on-error: true

      - name: Transpile ts
        run: pnpm exec tsc .github/workflows/commentCodeGeneration.ts --outDir .github/workflows

      - name: Comment
        uses: actions/github-script@v6
        with:
          script: |
            const script = require('${{ github.workspace }}/.github/workflows/commentCodeGeneration.js')
            await script(github, context, ${{ steps.generate.outcome == 'success' && steps.diff.outcome == 'success' }})

      - name: Status
        if: ${{ steps.generate.outcome == 'failure' || steps.diff.outcome == 'failure' }}
        run: exit 1