forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (69 loc) · 2.62 KB
/
code-generation.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
78
79
name: Code Generation
on:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # 00:00 UTC Weekly on Mondays
jobs:
up_to_date:
name: Ensure Generated Code Up To Date
if: github.event_name != 'schedule' || github.repository == 'opensearch-project/opensearch-java'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Java Client
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'
- name: Download Latest Spec
if: github.event_name != 'pull_request'
run: ./gradlew :java-codegen:downloadLatestSpec
- name: Run Code Generator
run: ./gradlew :java-codegen:run
- name: Git Status
id: status
shell: bash -eo pipefail {0}
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
output=$(git status --porcelain)
if [ -z "$output" ]; then
echo "Clean working directory"
echo "clean=true" >> $GITHUB_OUTPUT
else
echo "Dirty working directory"
echo "$output"
echo "clean=false" >> $GITHUB_OUTPUT
fi
- name: Fail On Uncommitted Changes
if: github.event_name == 'pull_request' && steps.status.outputs.clean != 'true'
run: exit 1
- name: Generate GitHub App Token
if: github.repository == 'opensearch-project/opensearch-java' && github.event_name != 'pull_request' && steps.status.outputs.clean != 'true'
id: github_app_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780
- name: Create Pull Request
if: github.event_name != 'pull_request' && steps.status.outputs.clean != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}
commit-message: Re-generate client code using latest OpenSearch API specification (${{ steps.status.outputs.date }})
title: Re-generated client code using latest OpenSearch API specification
body: |
Re-generated client code using latest OpenSearch API specification.
Date: ${{ steps.status.outputs.date }}
branch: code-gen/${{ github.ref_name }}/update
signoff: true
labels: |
autocut