-
Notifications
You must be signed in to change notification settings - Fork 236
48 lines (43 loc) · 1.5 KB
/
generated-code.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
name: Generate code and open pull request
on:
workflow_dispatch:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/checkout@v4
with:
submodules: recursive
- name: Update submodules
run: git submodule update --remote --recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Generate code
run: |
python generate-code.py
diff=$(git --no-pager diff --name-only HEAD)
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b update-diff-${{ env.CURRENT_DATETIME }}
git add .
git commit -m "Code are generated by openapi generator"
git push origin update-diff-${{ env.CURRENT_DATETIME }}
gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi generator" -b "" --label "line-openapi-update"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}