Update Proto Dependency #10
Workflow file for this run
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: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.APTOS_BOT_PAT }} | |
- name: Configure Git | |
run: | | |
git config user.name "aptos-bot" | |
git config user.email "[email protected]" | |
git remote set-url origin https://x-access-token:${{ secrets.APTOS_BOT_PAT }}@github.com/aptos-labs/aptos-indexer-processor-sdk.git | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Install toml | |
run: cargo install toml-cli | |
- 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: 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: ${{ secrets.APTOS_BOT_PAT }} | |
working-directory: aptos-indexer-processors-sdk/ | |
- name: Check if PR Already Exists | |
id: check_pr | |
run: | | |
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: ${{ secrets.APTOS_BOT_PAT }} | |
- name: Create Pull Request | |
if: steps.check_pr.outputs.if_pr_exists == 'false' | |
run: | | |
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: ${{ secrets.APTOS_BOT_PAT }} |