-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (73 loc) · 2.34 KB
/
regenerate.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
70
71
72
73
74
75
76
77
name: Regenerate
on:
workflow_dispatch:
concurrency:
group: openapi-regenerate
jobs:
check-diff:
name: check diff
runs-on: ubuntu-latest
outputs:
has_diff: ${{ steps.check-diff.outputs.has_diff }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: restore diff cache
uses: actions/cache@v3
with:
path: ./tmp
key: diff
- name: Check diff
id: check-diff
run: |
touch tmp
git clone https://github.com/traPtitech/traQ
cd traQ
git log --oneline -1 -- 'docs/v3-api.yaml' | sed -e "s/ .*$//" > ../tmp_new
cd ..
rm -rf traQ
cat tmp_new
if diff tmp tmp_new > /dev/null; then
echo "has_diff=false" >> "$GITHUB_OUTPUT"
else
echo "has_diff=true" >> "$GITHUB_OUTPUT"
fi
mv tmp_new tmp
regenerate:
name: regenerate
runs-on: ubuntu-latest
needs: check-diff
if: needs.check-diff.outputs.has_diff == 'true'
permissions:
contents: write
pull-requests: write
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- name: install openapi-generator
run: |
OPENAPI_GENERATOR_VERSION=`cat .openapi-generator/VERSION`
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_GENERATOR_VERSION}/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar -O openapi-generator-cli.jar
- name: build
run: sh ./generate.sh
- name: uninstall openapi-generator
run: rm openapi-generator-cli.jar
- name: git commit and push
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
BRANCH_NAME="update-$(date +'%Y%m%d%H%M%S')"
git switch -c "$BRANCH_NAME"
git add .
git commit -m "CI: regenerate [skip ci]" --author="H1rono <54711422+H1rono@users.noreply.github.com>"
git push origin "$BRANCH_NAME"
- name: create pull request
run: |
gh pr create --title "CI: regenerate" --body "" --base main --assignee H1rono
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}