Auto Proto Convert #105
This file contains hidden or 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
| name: Auto Proto Convert | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| input_param: | |
| description: '' | |
| required: false | |
| jobs: | |
| auto-proto-convert: | |
| runs-on: ubuntu-latest | |
| #if: github.repository == 'opensearch-project/opensearch-protobufs' | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| - name: Setup Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: temurin | |
| java-version: 25 | |
| - name: Install buf | |
| run: | | |
| npm install -g @bufbuild/buf | |
| buf --version | |
| - name: Download Release Assets | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: 'opensearch-project/opensearch-api-specification' | |
| latest: true | |
| fileName: 'opensearch-openapi.yaml' | |
| tag: 'main-latest' | |
| preRelease: true | |
| - name: Get Latest Commit ID | |
| id: get_commit | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const owner = "opensearch-project"; | |
| const repo = "opensearch-api-specification"; | |
| const commits = await github.rest.repos.listCommits({ | |
| owner, | |
| repo, | |
| sha: "main", | |
| per_page: 1 | |
| }); | |
| const latestCommit = commits.data[0].sha; | |
| core.setOutput("latest_commit", latestCommit); | |
| console.log("Latest commit: " + latestCommit); | |
| - name: Run Proto Conversion | |
| run: npm ci && npm run preprocessing | |
| - name: Clone Protobuf Generator Repository | |
| run: git clone https://github.com/OpenAPITools/openapi-generator cloned-repo | |
| - name: Build Protobuf Generator Tool | |
| run: | | |
| cd cloned-repo | |
| ./mvnw clean package | |
| - name: Convert protobuf | |
| run: | | |
| java -jar cloned-repo/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -c tools/proto-convert/src/config/protobuf-generator-config.yaml | |
| # - name: Post Process Protobuf | |
| # run: npm run postprocessing | |
| - name: Reformat proto files | |
| run: | | |
| buf format -w protos/generated | |
| - name: Configure Git User | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "No changes detected." | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected." | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request if changes exist | |
| if: steps.check_changes.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: auto-pr-branch | |
| commit-message: "Protobuf schema change detected" | |
| title: "[Automated PR]: Update generated protobuf schema (spec commit: ${{ steps.get_commit.outputs.latest_commit }})" | |
| signoff: true | |
| base: main | |
| delete-branch: true | |
| labels: skip-changelog | |
| body: | | |
| This pull request was automatically generated by GitHub Actions. |