|
| 1 | +# Deploy fisherman network with specified L1 network |
| 2 | +# This workflow can be called directly or from other workflows |
| 3 | +name: Deploy Fisherman Network |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + l1_network: |
| 9 | + description: "L1 network (sepolia or mainnet)" |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + semver: |
| 13 | + description: "Semver version (e.g., 2.3.4)" |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + ref: |
| 17 | + description: "Git ref to checkout" |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + l1_network: |
| 23 | + description: "L1 network (sepolia or mainnet)" |
| 24 | + required: true |
| 25 | + type: choice |
| 26 | + options: |
| 27 | + - sepolia |
| 28 | + - mainnet |
| 29 | + semver: |
| 30 | + description: "Semver version (e.g., 2.3.4)" |
| 31 | + required: true |
| 32 | + type: string |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: deploy-fisherman-network-${{ inputs.l1_network }}-${{ inputs.semver }}-${{ github.ref || github.ref_name }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +jobs: |
| 39 | + deploy-fisherman: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + env: |
| 42 | + GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp-key.json |
| 43 | + steps: |
| 44 | + - name: Determine checkout ref |
| 45 | + id: checkout-ref |
| 46 | + run: | |
| 47 | + # Use inputs.ref if provided (workflow_call), otherwise use github.ref |
| 48 | + if [[ -n "${{ inputs.ref }}" ]]; then |
| 49 | + echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT |
| 50 | + else |
| 51 | + echo "ref=${{ github.ref }}" >> $GITHUB_OUTPUT |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 56 | + with: |
| 57 | + ref: ${{ steps.checkout-ref.outputs.ref }} |
| 58 | + fetch-depth: 0 |
| 59 | + persist-credentials: false |
| 60 | + submodules: recursive # Initialize git submodules for l1-contracts dependencies |
| 61 | + |
| 62 | + - name: Validate inputs |
| 63 | + run: | |
| 64 | + # Validate l1_network |
| 65 | + if [[ "${{ inputs.l1_network }}" != "sepolia" && "${{ inputs.l1_network }}" != "mainnet" ]]; then |
| 66 | + echo "Error: L1 network must be 'sepolia' or 'mainnet', got '${{ inputs.l1_network }}'" |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | +
|
| 70 | + # Validate environment file exists |
| 71 | + if [[ ! -f "spartan/environments/ignition-fisherman.env" ]]; then |
| 72 | + echo "Error: Environment file not found: spartan/environments/ignition-fisherman.env" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + # Validate semver format |
| 77 | + if ! echo "${{ inputs.semver }}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$'; then |
| 78 | + echo "Error: Invalid semver format '${{ inputs.semver }}'. Expected format: X.Y.Z or X.Y.Z-suffix" |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +
|
| 82 | + # Extract major version for v2 check |
| 83 | + major_version="${{ inputs.semver }}" |
| 84 | + major_version="${major_version%%.*}" |
| 85 | + echo "MAJOR_VERSION=$major_version" >> $GITHUB_ENV |
| 86 | +
|
| 87 | + - name: Store the GCP key in a file |
| 88 | + env: |
| 89 | + GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} |
| 90 | + run: | |
| 91 | + set +x |
| 92 | + umask 077 |
| 93 | + printf '%s' "$GCP_SA_KEY" > "$GOOGLE_APPLICATION_CREDENTIALS" |
| 94 | + jq -e . "$GOOGLE_APPLICATION_CREDENTIALS" >/dev/null |
| 95 | +
|
| 96 | + - name: Setup GCP authentication |
| 97 | + run: | |
| 98 | + gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS" |
| 99 | +
|
| 100 | + - name: Setup gcloud and install GKE auth plugin |
| 101 | + uses: google-github-actions/setup-gcloud@v2 |
| 102 | + with: |
| 103 | + install_components: "gke-gcloud-auth-plugin" |
| 104 | + |
| 105 | + - name: Setup Terraform |
| 106 | + uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 |
| 107 | + with: |
| 108 | + terraform_version: "1.7.5" |
| 109 | + terraform_wrapper: false # Disable the wrapper that adds debug output, this messes with reading terraform output |
| 110 | + |
| 111 | + - name: Install Foundry |
| 112 | + uses: foundry-rs/foundry-toolchain@v1 |
| 113 | + |
| 114 | + - name: Set environment variables |
| 115 | + run: | |
| 116 | + # Set environment variables for ignition-fisherman.env |
| 117 | + if [[ "${{ inputs.l1_network }}" == "sepolia" ]]; then |
| 118 | + echo "NETWORK=staging-ignition" >> $GITHUB_ENV |
| 119 | + echo "NAMESPACE=ignition-fisherman-sepolia" >> $GITHUB_ENV |
| 120 | + echo "ETHEREUM_CHAIN_ID=11155111" >> $GITHUB_ENV |
| 121 | + echo "L1_NETWORK=sepolia" >> $GITHUB_ENV |
| 122 | + echo "SNAPSHOT_BUCKET_DIRECTORY=ignition-sepolia" >> $GITHUB_ENV |
| 123 | + echo "USE_NETWORK_CONFIG=true" >> $GITHUB_ENV |
| 124 | + elif [[ "${{ inputs.l1_network }}" == "mainnet" ]]; then |
| 125 | + echo "NETWORK=mainnet" >> $GITHUB_ENV |
| 126 | + echo "NAMESPACE=ignition-fisherman-mainnet" >> $GITHUB_ENV |
| 127 | + echo "ETHEREUM_CHAIN_ID=1" >> $GITHUB_ENV |
| 128 | + echo "L1_NETWORK=mainnet" >> $GITHUB_ENV |
| 129 | + echo "SNAPSHOT_BUCKET_DIRECTORY=ignition-mainnet" >> $GITHUB_ENV |
| 130 | + echo "USE_NETWORK_CONFIG=true" >> $GITHUB_ENV |
| 131 | + fi |
| 132 | +
|
| 133 | + - name: Deploy fisherman network |
| 134 | + env: |
| 135 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 136 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 137 | + GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} |
| 138 | + RUN_ID: ${{ github.run_id }} |
| 139 | + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
| 140 | + GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }} |
| 141 | + REF_NAME: "v${{ inputs.semver }}" |
| 142 | + GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} |
| 143 | + AZTEC_DOCKER_IMAGE: "aztecprotocol/aztec:${{ inputs.semver }}" |
| 144 | + run: | |
| 145 | + echo "Deploying fisherman network on L1: ${{ inputs.l1_network }}" |
| 146 | + echo "Using image: $AZTEC_DOCKER_IMAGE" |
| 147 | + echo "Using branch/ref: ${{ steps.checkout-ref.outputs.ref }}" |
| 148 | + echo "Network: $NETWORK" |
| 149 | + echo "Namespace: $NAMESPACE" |
| 150 | + echo "Ethereum Chain ID: $ETHEREUM_CHAIN_ID" |
| 151 | + echo "L1 Network: $L1_NETWORK" |
| 152 | + echo "Snapshot Bucket Directory: $SNAPSHOT_BUCKET_DIRECTORY" |
| 153 | + echo "Use Network Config: $USE_NETWORK_CONFIG" |
| 154 | +
|
| 155 | + cd spartan |
| 156 | + ./scripts/install_deps.sh |
| 157 | + ./scripts/network_deploy.sh ignition-fisherman |
| 158 | +
|
| 159 | + - name: Setup IRM |
| 160 | + env: |
| 161 | + MONITORING_NAMESPACE: ${{ env.NETWORK }}-irm |
| 162 | + INFURA_SECRET_NAME: infura-${{ env.L1_NETWORK }}-url |
| 163 | + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 164 | + run: | |
| 165 | +
|
| 166 | + echo "Setting up IRM for namespace: $NAMESPACE, monitoring namespace: $MONITORING_NAMESPACE" |
| 167 | + echo "Network: $NETWORK" |
| 168 | +
|
| 169 | + echo "INFURA Secret Name: $INFURA_SECRET_NAME" |
| 170 | +
|
| 171 | + ./spartan/metrics/testnet-monitor/scripts/update-monitoring.sh $NAMESPACE ${{ env.MONITORING_NAMESPACE }} $NETWORK $INFURA_SECRET_NAME |
| 172 | +
|
| 173 | + - name: Notify Slack on failure |
| 174 | + if: failure() |
| 175 | + env: |
| 176 | + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
| 177 | + run: | |
| 178 | + if [ -n "${SLACK_BOT_TOKEN}" ]; then |
| 179 | + read -r -d '' data <<EOF || true |
| 180 | + { |
| 181 | + "channel": "#alerts-fisherman-${{ inputs.l1_network }}", |
| 182 | + "text": "Deploy Fisherman Network workflow FAILED for *${{ inputs.l1_network }}* (version ${{ inputs.semver }}): <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>" |
| 183 | + } |
| 184 | + EOF |
| 185 | + curl -X POST https://slack.com/api/chat.postMessage \ |
| 186 | + -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ |
| 187 | + -H "Content-type: application/json" \ |
| 188 | + --data "$data" |
| 189 | + fi |
0 commit comments