-
Notifications
You must be signed in to change notification settings - Fork 3
experimental workflow for adding a new chain to proto #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
poopoothegorilla
wants to merge
4
commits into
main
Choose a base branch
from
jtw/experimental-plex-gha
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,254 @@ | ||
| name: Add New EVM Chain | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| chain-selector: | ||
| description: 'The chain selector value (uint64)' | ||
| required: true | ||
| type: string | ||
| dry-run: | ||
| description: 'Dry run mode - show what would be done without making changes' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| workflow_call: | ||
| inputs: | ||
| chain-selector: | ||
| description: 'The chain selector value (uint64)' | ||
| required: true | ||
| type: string | ||
| dry-run: | ||
| description: 'Dry run mode - show what would be done without making changes' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ inputs.chain-selector }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| add-new-evm-chain: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| outputs: | ||
| chain-name: ${{ steps.run-tool.outputs.chain_name }} | ||
| action: ${{ steps.run-tool.outputs.action }} | ||
| pr-url: ${{ steps.create-pr.outputs.pr_url }} | ||
| steps: | ||
| - name: Validate inputs | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| CHAIN_SELECTOR="${{ inputs.chain-selector }}" | ||
|
|
||
| # Validate chain-selector is a positive integer (uint64) | ||
| if ! [[ "$CHAIN_SELECTOR" =~ ^[0-9]+$ ]]; then | ||
| echo "::error::chain-selector must be a positive integer, got: $CHAIN_SELECTOR" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate it's within uint64 range (max: 18446744073709551615) | ||
| if [[ ${#CHAIN_SELECTOR} -gt 20 ]]; then | ||
| echo "::error::chain-selector exceeds uint64 maximum value" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "::notice::Input validation passed: chain-selector=$CHAIN_SELECTOR" | ||
|
|
||
| - name: Assume AWS GATI role | ||
| uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN_GATI }} | ||
| role-duration-seconds: 900 | ||
| aws-region: ${{ secrets.AWS_REGION }} | ||
| mask-aws-account-id: true | ||
|
|
||
| - name: Get GitHub token from GATI | ||
| id: get-gh-token | ||
| uses: smartcontractkit/chainlink-github-actions/github-app-token-issuer@main | ||
| with: | ||
| url: ${{ secrets.AWS_LAMBDA_URL_GATI }} | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
| with: | ||
| token: ${{ steps.get-gh-token.outputs.access-token }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set tool versions to env vars | ||
| id: tool-versions | ||
| uses: smartcontractkit/tool-versions-to-env-action@aabd5efbaf28005284e846c5cf3a02f2cba2f4c2 # v1.0.8 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.0 | ||
| with: | ||
| go-version: ${{ steps.tool-versions.outputs.golang_version }} | ||
|
|
||
| - name: Build add-new-evm-chain tool | ||
| run: | | ||
| set -euo pipefail | ||
| cd cre/go | ||
| go build -o add-new-evm-chain ./tools/add-new-evm-chain | ||
|
|
||
| - name: Run add-new-evm-chain tool | ||
| id: run-tool | ||
| env: | ||
| INPUT_CHAIN_SELECTOR: ${{ inputs.chain-selector }} | ||
| INPUT_DRY_RUN: ${{ inputs.dry-run }} | ||
| run: | | ||
| set -euo pipefail | ||
| cd cre/go | ||
|
|
||
| # Build command arguments | ||
| ARGS="-chain-selector $INPUT_CHAIN_SELECTOR -proto-file ../capabilities/blockchain/evm/v1alpha/client.proto" | ||
| if [[ "$INPUT_DRY_RUN" == "true" ]]; then | ||
| ARGS="$ARGS -dry-run" | ||
| fi | ||
|
|
||
| # Run tool and capture output | ||
| echo "::group::Tool output" | ||
| if ! OUTPUT=$(./add-new-evm-chain $ARGS 2>&1); then | ||
| echo "$OUTPUT" | ||
| echo "::endgroup::" | ||
|
|
||
| # Try to parse ACTION even on failure | ||
| ACTION=$(echo "$OUTPUT" | grep "^ACTION=" | cut -d'=' -f2 || echo "error") | ||
| echo "action=$ACTION" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "::error::Tool execution failed" | ||
| exit 1 | ||
| fi | ||
| echo "$OUTPUT" | ||
| echo "::endgroup::" | ||
|
|
||
| # Parse structured output | ||
| CHAIN_NAME=$(echo "$OUTPUT" | grep "^CHAIN_NAME=" | cut -d'=' -f2) | ||
| CHAIN_SELECTOR=$(echo "$OUTPUT" | grep "^CHAIN_SELECTOR=" | cut -d'=' -f2) | ||
| ACTION=$(echo "$OUTPUT" | grep "^ACTION=" | cut -d'=' -f2) | ||
|
|
||
| # Validate outputs | ||
| if [[ -z "$CHAIN_NAME" || -z "$ACTION" ]]; then | ||
| echo "::error::Failed to parse tool output - missing CHAIN_NAME or ACTION" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "chain_name=$CHAIN_NAME" >> $GITHUB_OUTPUT | ||
| echo "chain_selector=$CHAIN_SELECTOR" >> $GITHUB_OUTPUT | ||
| echo "action=$ACTION" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "::notice::Chain: $CHAIN_NAME, Selector: $CHAIN_SELECTOR, Action: $ACTION" | ||
|
|
||
| - name: Sanitize chain name for branch | ||
| id: sanitize | ||
| if: ${{ !inputs.dry-run && steps.run-tool.outputs.action == 'added' }} | ||
| env: | ||
| CHAIN_NAME: ${{ steps.run-tool.outputs.chain_name }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Sanitize chain name for use in git branch names | ||
| # Only allow alphanumeric, hyphens, and underscores | ||
| SAFE_CHAIN_NAME=$(echo "$CHAIN_NAME" | tr -cd '[:alnum:]-_' | tr '[:upper:]' '[:lower:]') | ||
|
|
||
| if [[ -z "$SAFE_CHAIN_NAME" ]]; then | ||
| echo "::error::Chain name sanitization resulted in empty string" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "safe_chain_name=$SAFE_CHAIN_NAME" >> $GITHUB_OUTPUT | ||
| echo "::notice::Sanitized chain name: $SAFE_CHAIN_NAME" | ||
|
|
||
| - name: Create branch for PR | ||
| if: ${{ !inputs.dry-run && steps.run-tool.outputs.action == 'added' }} | ||
| id: create-branch | ||
| env: | ||
| SAFE_CHAIN_NAME: ${{ steps.sanitize.outputs.safe_chain_name }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| BRANCH_NAME="add-evm-chain/${SAFE_CHAIN_NAME}-$(date +%Y%m%d-%H%M%S)" | ||
| echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
|
|
||
| git checkout -b "$BRANCH_NAME" | ||
| echo "::notice::Created branch: $BRANCH_NAME" | ||
|
|
||
| - name: Commit changes using ghcommit | ||
| if: ${{ !inputs.dry-run && steps.run-tool.outputs.action == 'added' }} | ||
| uses: planetscale/[email protected] | ||
Check warningCode scanning / CodeQL Unpinned tag for a non-immutable Action in workflow Medium
Unpinned 3rd party Action 'Add New EVM Chain' step
Uses Step Error loading related location Loading |
||
| with: | ||
| commit_message: "feat(cre): add EVM chain ${{ steps.run-tool.outputs.chain_name }}" | ||
| repo: ${{ github.repository }} | ||
| branch: ${{ steps.create-branch.outputs.branch_name }} | ||
| file_pattern: "cre/capabilities/blockchain/evm/v1alpha/client.proto" | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.get-gh-token.outputs.access-token }} | ||
|
|
||
| - name: Create Pull Request | ||
| if: ${{ !inputs.dry-run && steps.run-tool.outputs.action == 'added' }} | ||
| id: create-pr | ||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
| env: | ||
| CHAIN_NAME: ${{ steps.run-tool.outputs.chain_name }} | ||
| CHAIN_SELECTOR: ${{ steps.run-tool.outputs.chain_selector }} | ||
| BRANCH_NAME: ${{ steps.create-branch.outputs.branch_name }} | ||
| with: | ||
| github-token: ${{ steps.get-gh-token.outputs.access-token }} | ||
| script: | | ||
| const chainName = process.env.CHAIN_NAME; | ||
| const chainSelector = process.env.CHAIN_SELECTOR; | ||
| const branchName = process.env.BRANCH_NAME; | ||
|
|
||
| const { data: pr } = await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `feat(cre): add EVM chain ${chainName}`, | ||
| head: branchName, | ||
| base: 'main', | ||
| body: `## Summary | ||
|
|
||
| This PR adds the EVM chain **${chainName}** to the CRE client.proto file. | ||
|
|
||
| ### Chain Details | ||
| - **Chain Name**: ${chainName} | ||
| - **Selector**: ${chainSelector} | ||
|
|
||
| ### Changes | ||
| - Added entry to \`cre/capabilities/blockchain/evm/v1alpha/client.proto\` | ||
|
|
||
| --- | ||
| *This PR was automatically generated by the add-new-evm-chain workflow.* | ||
| `, | ||
| maintainer_can_modify: true | ||
| }); | ||
|
|
||
| core.setOutput('pr_url', pr.html_url); | ||
| core.notice(`Created PR: ${pr.html_url}`); | ||
|
|
||
| - name: Summary | ||
| env: | ||
| CHAIN_NAME: ${{ steps.run-tool.outputs.chain_name }} | ||
| CHAIN_SELECTOR: ${{ steps.run-tool.outputs.chain_selector }} | ||
| ACTION: ${{ steps.run-tool.outputs.action }} | ||
| DRY_RUN: ${{ inputs.dry-run }} | ||
| PR_URL: ${{ steps.create-pr.outputs.pr_url }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| echo "## Add New EVM Chain Results" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY | ||
| echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Chain Name | $CHAIN_NAME |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Chain Selector | $CHAIN_SELECTOR |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Action | $ACTION |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Dry Run | $DRY_RUN |" >> $GITHUB_STEP_SUMMARY | ||
| if [[ -n "$PR_URL" ]]; then | ||
| echo "| PR URL | $PR_URL |" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium