sdk-dependency-update #5
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 SDK Dependency | |
| on: | |
| repository_dispatch: | |
| types: [sdk-dependency-update] | |
| workflow_dispatch: | |
| inputs: | |
| branch_name: | |
| type: string | |
| default: "main" | |
| commit_hash: | |
| type: string | |
| default: "main" | |
| aptos_protos_commit_hash: | |
| type: string | |
| default: "main" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| jobs: | |
| update-the-dependency: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: auth | |
| uses: "google-github-actions/auth@v2" | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | |
| - name: Get Secret Manager Secrets | |
| id: secrets | |
| uses: 'google-github-actions/get-secretmanager-secrets@v2' | |
| with: | |
| secrets: |- | |
| token:aptos-ci/github-actions-repository-dispatch | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.secrets.outputs.token }} | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Install toml | |
| run: cargo install toml-cli | |
| - name: Update the dependency | |
| run: | | |
| set -e | |
| # Use workflow_dispatch inputs if available, otherwise use repository_dispatch values | |
| commit_hash="${{ github.event.inputs.commit_hash || github.event.client_payload.commit_hash }}" | |
| aptos_protos_commit_hash="${{ github.event.inputs.aptos_protos_commit_hash || github.event.client_payload.aptos_protos_commit_hash }}" | |
| branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}" | |
| # SDK commit hash SDK + framework + testing. | |
| toml set Cargo.toml workspace.dependencies.aptos-indexer-processor-sdk.rev "$commit_hash" > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
| toml set Cargo.toml workspace.dependencies.aptos-indexer-processor-sdk-server-framework.rev "$commit_hash" > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
| toml set Cargo.toml workspace.dependencies.aptos-indexer-testing-framework.rev "$commit_hash" > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
| # Protos commit hash | |
| toml set Cargo.toml workspace.dependencies.aptos-protos.rev "$aptos_protos_commit_hash" > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
| toml set Cargo.toml workspace.dependencies.aptos-indexer-test-transactions.rev "$aptos_protos_commit_hash" > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
| # Refresh the lock file | |
| cargo build | |
| working-directory: rust/ | |
| - name: Configure Git user | |
| run: | | |
| git config --global user.name "Aptos Bot" | |
| git config --global user.email "[email protected]" | |
| - name: Commit and Push Changes | |
| run: | | |
| set -e | |
| branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-sdk" | |
| commit_hash="${{ github.event.inputs.commit_hash || github.event.client_payload.commit_hash }}" | |
| git checkout -b "$branch_name" | |
| git add Cargo.toml | |
| git add Cargo.lock | |
| git commit -m "Update sdk to $commit_hash" | |
| git push origin "$branch_name" --force | |
| env: | |
| GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} | |
| working-directory: rust/ | |
| - name: Create Pull Request | |
| run: | | |
| branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-sdk" | |
| gh pr create --title "Update sdk to upstream branch ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}" \ | |
| --body "This PR updates sdk to new version." \ | |
| --base main \ | |
| --head "$branch_name" \ | |
| --label "indexer-sdk-update" | |
| env: | |
| GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} | |
| - name: Run Integration Tests | |
| run: cargo test --manifest-path integration-tests/Cargo.toml | |
| working-directory: rust |