proto-dependency-update #24
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: Update Proto Dependency | |
on: | |
repository_dispatch: | |
types: [proto-dependency-update] | |
workflow_dispatch: | |
inputs: | |
commit_hash: | |
description: 'Commit hash to update proto to' | |
required: true | |
branch_name: | |
description: 'Branch name (without -update-aptos-protos suffix)' | |
required: true | |
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: Configure Git user | |
run: | | |
git config --global user.name "Aptos Bot" | |
git config --global user.email "[email protected]" | |
- 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 | |
toml set Cargo.toml workspace.dependencies.aptos-protos.rev ${{ github.event.inputs.commit_hash || github.event.client_payload.commit_hash }} > Cargo.tmp && mv Cargo.tmp Cargo.toml | |
working-directory: aptos-indexer-processors-sdk/ | |
- name: Commit and Push Changes | |
run: | | |
set -e | |
branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-aptos-protos" | |
git checkout -b "$branch_name" | |
git add Cargo.toml | |
git commit -m "Update aptos-protos to ${{ github.event.inputs.commit_hash || github.event.client_payload.commit_hash }}" | |
git push origin "$branch_name" --force | |
env: | |
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} | |
working-directory: aptos-indexer-processors-sdk/ | |
- name: Check if PR Already Exists | |
id: check_pr | |
run: | | |
branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-aptos-protos" | |
existing_pr=$(gh pr list --base main --head "$branch_name" --json number --jq '.[].number') | |
if [ -n "$existing_pr" ]; then | |
echo "::set-output name=if_pr_exists::true" | |
else | |
echo "::set-output name=if_pr_exists::false" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} | |
- name: Create Pull Request | |
if: steps.check_pr.outputs.if_pr_exists == 'false' | |
run: | | |
branch_name="${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}-update-aptos-protos" | |
gh pr create --title "Update aptos-protos to upstream branch ${{ github.event.client_payload.branch_name }}" \ | |
--body "This PR updates aptos-protos to new version." \ | |
--base main \ | |
--head "$branch_name" \ | |
--label "indexer-sdk-update" | |
env: | |
GITHUB_TOKEN: ${{ steps.secrets.outputs.token }} |