|
| 1 | +# Deploy a single staging network |
| 2 | +# This workflow can be called directly or from other workflows |
| 3 | +name: Deploy Staging Network |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + network: |
| 9 | + description: 'Network to deploy (e.g., staging-public, staging-ignition, testnet)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + semver: |
| 13 | + description: 'Semver version (e.g., 2.3.4)' |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + network: |
| 19 | + description: 'Network to deploy (e.g., staging-public, staging-ignition, testnet)' |
| 20 | + required: true |
| 21 | + type: choice |
| 22 | + options: |
| 23 | + - staging-public |
| 24 | + - staging-ignition |
| 25 | + - testnet |
| 26 | + semver: |
| 27 | + description: 'Semver version (e.g., 2.3.4)' |
| 28 | + required: true |
| 29 | + type: string |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: deploy-staging-network-${{ inputs.network }}-${{ inputs.semver }}-${{ github.ref || github.ref_name }} |
| 33 | + cancel-in-progress: true |
| 34 | + |
| 35 | +jobs: |
| 36 | + deploy-network: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + env: |
| 39 | + GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp-key.json |
| 40 | + steps: |
| 41 | + - name: Determine checkout ref |
| 42 | + id: checkout-ref |
| 43 | + run: | |
| 44 | + if [[ -n "${{ github.ref }}" ]]; then |
| 45 | + echo "ref=${{ github.ref }}" >> $GITHUB_OUTPUT |
| 46 | + elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 47 | + echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT |
| 48 | + else |
| 49 | + echo "ref=${{ github.ref }}" >> $GITHUB_OUTPUT |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 54 | + with: |
| 55 | + ref: ${{ steps.checkout-ref.outputs.ref }} |
| 56 | + fetch-depth: 0 |
| 57 | + persist-credentials: false |
| 58 | + |
| 59 | + - name: Validate inputs |
| 60 | + run: | |
| 61 | + # Validate network |
| 62 | + if [[ ! -f "spartan/environments/${{ inputs.network }}.env" ]]; then |
| 63 | + echo "Error: Environment file not found for network '${{ inputs.network }}'" |
| 64 | + echo "Available networks:" |
| 65 | + ls -1 spartan/environments/ | grep -v '\.local\.env$' || echo "No environment files found" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + # Validate semver format |
| 70 | + if ! echo "${{ inputs.semver }}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$'; then |
| 71 | + echo "Error: Invalid semver format '${{ inputs.semver }}'. Expected format: X.Y.Z or X.Y.Z-suffix" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + # Extract major version for v2 check |
| 76 | + major_version="${{ inputs.semver }}" |
| 77 | + major_version="${major_version%%.*}" |
| 78 | + echo "MAJOR_VERSION=$major_version" >> $GITHUB_ENV |
| 79 | +
|
| 80 | + - name: Store the GCP key in a file |
| 81 | + if: env.MAJOR_VERSION == '2' |
| 82 | + env: |
| 83 | + GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} |
| 84 | + run: | |
| 85 | + set +x |
| 86 | + umask 077 |
| 87 | + printf '%s' "$GCP_SA_KEY" > "$GOOGLE_APPLICATION_CREDENTIALS" |
| 88 | + jq -e . "$GOOGLE_APPLICATION_CREDENTIALS" >/dev/null |
| 89 | +
|
| 90 | + - name: Setup GCP authentication |
| 91 | + if: env.MAJOR_VERSION == '2' |
| 92 | + run: | |
| 93 | + gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS" |
| 94 | +
|
| 95 | + - name: Deploy network |
| 96 | + if: env.MAJOR_VERSION == '2' |
| 97 | + env: |
| 98 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 99 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 100 | + GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} |
| 101 | + RUN_ID: ${{ github.run_id }} |
| 102 | + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
| 103 | + GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }} |
| 104 | + REF_NAME: "v${{ inputs.semver }}" |
| 105 | + GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} |
| 106 | + AZTEC_DOCKER_IMAGE: "aztecprotocol/aztec:${{ inputs.semver }}" |
| 107 | + run: | |
| 108 | + echo "Deploying network: ${{ inputs.network }}" |
| 109 | + echo "Using image: $AZTEC_DOCKER_IMAGE" |
| 110 | + echo "Using branch/ref: ${{ steps.checkout-ref.outputs.ref }}" |
| 111 | +
|
| 112 | + cd spartan |
| 113 | + ./bootstrap.sh network_deploy "${{ inputs.network }}" |
| 114 | +
|
| 115 | + - name: Update testnet monitoring (testnet only) |
| 116 | + if: env.MAJOR_VERSION == '2' && inputs.network == 'testnet' && !contains(inputs.semver, '-') |
| 117 | + env: |
| 118 | + MONITORING_NAMESPACE: testnet-block-height-monitor |
| 119 | + run: | |
| 120 | + echo "Updating monitoring app for testnet deployment..." |
| 121 | + ./spartan/metrics/testnet-monitor/scripts/update-monitoring.sh testnet ${{ env.MONITORING_NAMESPACE }} |
0 commit comments