From 4114893832f7d2d2f49bdb5ad7561dd62c947384 Mon Sep 17 00:00:00 2001 From: Yuun Lim <38443641+yuunlimm@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:26:05 -0700 Subject: [PATCH] allow cross repo workflow trigger (#526) --- .github/workflows/integration-tests.yaml | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index a1dbc834f..859915ff9 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -1,7 +1,14 @@ name: Run Integration Tests on: + repository_dispatch: + types: [json-change-detected] # Custom event type to trigger the workflow workflow_dispatch: + inputs: + commit_hash: + description: 'Commit hash to use for the dependency update' + required: true + default: 'main' push: branches: - main @@ -20,6 +27,35 @@ jobs: with: working-directory: rust + - name: list files + run: ls -la + +# update commite haash in the cargo.toml and run tests + - name: Show Cargo.toml Before Update + run: cat Cargo.toml # Print the contents of Cargo.toml before the update + + # Update the Cargo.toml with the provided commit hash + - name: Update Cargo.toml with new commit hash + run: | + echo "Updating dependency in Cargo.toml to use commit hash ${{ github.event.inputs.commit_hash }}" + sed -i 's|git = "https://github.com/yuunlimm/test-workflow2.git", rev = ".*"|git = "https://github.com/yuunlimm/test-workflow2.git", rev = "${{ github.event.inputs.commit_hash }}"|g' demo/Cargo.toml + + # Update the aptos-system-utils dependency + - name: Update aptos-system-utils dependency + run: | + echo "Updating aptos-system-utils dependency in Cargo.toml to use commit hash ${{ github.event.inputs.commit_hash }}" + sed -i '/aptos-system-utils = {/!b;n;s|rev = ".*"|rev = "${{ github.event.inputs.commit_hash }}"|' demo/Cargo.toml + + # Update the aptos-indexer-test-transactions dependency + - name: Update aptos-indexer-test-transactions dependency + run: | + echo "Updating aptos-indexer-test-transactions dependency in Cargo.toml to use commit hash ${{ github.event.inputs.commit_hash }}" + sed -i '/aptos-indexer-test-transactions = {/!b;n;s|rev = ".*"|rev = "${{ github.event.inputs.commit_hash }}"|' demo/Cargo.toml + + - name: Show Cargo.toml After Update + run: cat Cargo.toml + + - name: Run Integration Tests run: cargo test --manifest-path integration-tests/Cargo.toml working-directory: rust