Generate API from Spec #14
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
name: Generate API from Spec | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/generate_api.yml' | |
- 'api_generator/**' | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 0" # Every Sunday at midnight GMT | |
jobs: | |
generate-api: | |
if: ${{ github.repository == 'opensearch-project/opensearch-ruby' }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./api_generator | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Config git to rebase | |
run: git config --global pull.rebase true | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1 | |
- name: Update bundler | |
run: | | |
sudo apt-get update | |
sudo apt-get install libcurl4-openssl-dev | |
bundle install | |
- name: Generate API | |
run: |- | |
bundle exec rake download_spec | |
bundle exec rake generate_api | |
# This should only trigger on pull requests that modifies the api_generator directory | |
# and NOT on the scheduled workflow since the scheduled workflow will trigger the lint workflow instead. | |
- name: Lint generated files | |
if: ${{ github.event_name == 'pull_request' }} | |
working-directory: ./ | |
run: |- | |
bundle install | |
bundle exec rubocop | |
- name: Get current date | |
id: date | |
if: ${{ github.event_name != 'pull_request' }} | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: GitHub App token | |
id: github_app_token | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: tibdex/github-app-token@v2.1.0 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Create pull request | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ steps.github_app_token.outputs.token }} | |
commit-message: "Updated opensearch-ruby to reflect the latest OpenSearch API spec (${{ env.date }})" | |
title: "[AUTOCUT] Update opensearch-ruby to reflect the latest OpenSearch API spec (${{ env.date }})" | |
body: | | |
Update `opensearch-ruby` to reflect the latest [OpenSearch API spec](https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml). | |
Date: ${{ env.date }} | |
branch: update-api-from-spec-${{ env.date }} | |
base: main | |
signoff: true | |
labels: | | |
autocut |