[Github Actions] Copy OpenAPI spec v3.153.0 from monorepo #163
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: Update Rust SDK | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| update-sdk: | |
| if: false # Workflow disabled | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Dump GitHub context # Makes it much easier to retrospectively debug all sorts of workflow issues. Does NOT expose secrets. | |
| env: | |
| GITHUB_CONTEXT: ${{ toJson(github) }} | |
| run: echo "$GITHUB_CONTEXT" | |
| - name: Generate Neynar CI Bot token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.NEYNAR_CI_BOT_APP_ID }} | |
| private-key: ${{ secrets.NEYNAR_CI_BOT_PRIVATE_KEY }} | |
| owner: 'neynarxyz' | |
| repositories: 'rust-sdk' | |
| - name: Checkout OAS repository | |
| uses: actions/checkout@v3 | |
| - name: Checkout rust-sdk repository | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: "neynarxyz/rust-sdk.git" | |
| ref: "main" | |
| path: "rust-sdk" | |
| token: ${{ steps.generate-token.outputs.token }} | |
| submodules: recursive | |
| persist-credentials: true | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Update OAS submodule and package version in rust-sdk | |
| run: | | |
| # Get the author information from the OAS commit | |
| AUTHOR_NAME=$(git log -1 --format='%an') | |
| AUTHOR_EMAIL=$(git log -1 --format='%ae') | |
| cd rust-sdk | |
| # Update OAS submodule | |
| git submodule update --remote src/OAS | |
| # Set Git config using OAS commit author | |
| git config user.name "$AUTHOR_NAME (via Neynar CI Bot)" | |
| git config user.email "$AUTHOR_EMAIL" | |
| # Parse version from OAS | |
| # Install yq for YAML parsing | |
| sudo wget -O /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.24.5/yq_linux_amd64 | |
| sudo chmod +x /usr/bin/yq | |
| SDK_VERSION=$(yq e '.info."version"' src/OAS/src/api/spec.yaml) | |
| echo "SDK Version: $SDK_VERSION" | |
| # Check if SDK_VERSION is empty | |
| if [ -z "$SDK_VERSION" ]; then | |
| echo "Error: version not found in OAS file." | |
| exit 1 | |
| fi | |
| # Generate code | |
| export SDK_VERSION | |
| ./generate.sh | |
| # Stage and commit any changes | |
| if git diff --quiet; then | |
| echo "No changes to commit." | |
| exit 0 | |
| fi | |
| git add . | |
| git commit -m "[GitHub Actions] Generate Rust SDK v$SDK_VERSION from OAS repo" | |
| # Push directly to main using the bot credentials | |
| git push origin main | |
| shell: bash | |