Skip to content

Commit 356c3c3

Browse files
committed
generate code by github actions
1 parent 82f35c0 commit 356c3c3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/update-code.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Generate OpenAPI based code
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
tests:
11+
name: Generate OpenAPI based code
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Setup
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
- name: Update submodules
20+
run: git submodule update --remote --recursive
21+
- uses: actions/setup-node@v3
22+
id: setup_node_id
23+
with:
24+
node-version: 18
25+
- name: actions/setup-java@v3
26+
uses: actions/setup-java@v3
27+
with:
28+
distribution: 'temurin'
29+
java-version: 17
30+
architecture: x64
31+
32+
# Generate codes
33+
- run: |
34+
python3 generate-code.py
35+
# Run tests
36+
- run: npm run test
37+
- run: |
38+
diff=$(git --no-pager diff --name-only)
39+
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
40+
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
41+
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
42+
run: |
43+
git config user.name github-actions
44+
git config user.email github-actions@github.com
45+
git checkout -b update-diff-${{ env.CURRENT_DATETIME }}
46+
47+
git add src/**
48+
git commit --allow-empty -m "Codes are generated by openapi"
49+
50+
git push origin update-diff-${{ env.CURRENT_DATETIME }}
51+
gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi" -b "" --label "line-openapi-update"
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)