-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create PRs automatically updating code-gen weekly (#714)
Signed-off-by: Thomas Farr <[email protected]>
- Loading branch information
Showing
1 changed file
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
name: Code Generation | ||
|
||
on: [pull_request] | ||
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 == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout .NET Client | ||
|
@@ -26,7 +31,7 @@ jobs: | |
${{ runner.os }}-nuget- | ||
- name: Run Code Generator | ||
run: ./build.sh codegen --branch main | ||
run: ./build.sh codegen --branch main --include-high-level | ||
|
||
- name: Check For Uncommitted Changes | ||
shell: bash -eo pipefail {0} | ||
|
@@ -40,3 +45,60 @@ jobs: | |
echo "$output" | ||
exit 1 | ||
fi | ||
update_spec: | ||
name: Update Specification and Re-generate Code | ||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'schedule' && github.repository == 'opensearch-project/opensearch-net') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout .NET Client | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
5.0.x | ||
6.0.x | ||
- name: Cache Nuget Packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.?sproj') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: Download Latest Spec && Run Code Generator | ||
run: ./build.sh codegen --branch main --include-high-level --download | ||
|
||
- name: Get Current Date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Generate GitHub App Token | ||
if: github.repository == 'opensearch-project/opensearch-net' | ||
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 | ||
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.date.outputs.date }}) | ||
title: Re-generated client code using latest OpenSearch API specification | ||
body: | | ||
Re-generated client code using latest OpenSearch API specification. | ||
Date: ${{ steps.date.outputs.date }} | ||
branch: code-gen/${{ github.ref_name }}/update | ||
signoff: true | ||
labels: | | ||
autocut |