Deploy: Switch ENSNode Environment #36
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
| name: "Deploy: Switch ENSNode Environment" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: "New main environment (green or blue)" | |
| required: true | |
| type: choice | |
| options: | |
| - green | |
| - blue | |
| jobs: | |
| switch-environment: | |
| # NOTE: this needs to run on GH runner because of some obscure skopeo permissions thing | |
| runs-on: ubuntu-latest | |
| name: Switch Environment to ${{ inputs.target }} | |
| env: | |
| TARGET_ENVIRONMENT: ${{ inputs.target }} | |
| REDIS_URL: ${{ secrets.TRAEFIK_REDIS_URL }} | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Calculate env variables | |
| run: | | |
| case "$TARGET_ENVIRONMENT" in | |
| "green") | |
| echo "SLACK_TITLE=:large_green_circle: GREEN Environment Activated" >> "$GITHUB_ENV" | |
| echo "RAILWAY_ENVIRONMENT_ID=${{ secrets.GREEN_RAILWAY_ENVIRONMENT_ID }}" >> $GITHUB_ENV | |
| ;; | |
| "blue") | |
| echo "SLACK_TITLE=:large_blue_circle: BLUE Environment Activated" >> "$GITHUB_ENV" | |
| echo "RAILWAY_ENVIRONMENT_ID=${{ secrets.BLUE_RAILWAY_ENVIRONMENT_ID }}" >> $GITHUB_ENV | |
| ;; | |
| *) | |
| echo "SLACK_TITLE=:large_red_circle: Unrecognized Environment Activated" >> "$GITHUB_ENV" | |
| esac | |
| - name: Switch Traefik Routing | |
| run: | | |
| sudo apt update | |
| sudo apt install -y redis-tools | |
| # ALPHA | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/alpha-api-router/service "${TARGET_ENVIRONMENT}-alpha-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/alpha-indexer-router/service "${TARGET_ENVIRONMENT}-alpha-indexer" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-alpha-api-router/service "${TARGET_ENVIRONMENT}-alpha-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-alpha-indexer-router/service "${TARGET_ENVIRONMENT}-alpha-indexer" | |
| # MAINNET | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/mainnet-api-router/service "${TARGET_ENVIRONMENT}-mainnet-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/mainnet-indexer-router/service "${TARGET_ENVIRONMENT}-mainnet-indexer" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-mainnet-api-router/service "${TARGET_ENVIRONMENT}-alpha-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-mainnet-indexer-router/service "${TARGET_ENVIRONMENT}-alpha-indexer" | |
| # ALPHA-SEPOLIA | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/alpha-sepolia-api-router/service "${TARGET_ENVIRONMENT}-alpha-sepolia-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/alpha-sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-alpha-sepolia-indexer" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-alpha-sepolia-api-router/service "${TARGET_ENVIRONMENT}-alpha-sepolia-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-alpha-sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-alpha-sepolia-indexer" | |
| # SEPOLIA | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-sepolia-api-router/service "${TARGET_ENVIRONMENT}-sepolia-api" | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-sepolia-indexer" | |
| # ENSRAINBOW | |
| redis-cli -u $REDIS_URL SET traefik/http/routers/ensrainbow-api-router/service "${TARGET_ENVIRONMENT}-ensrainbow-api" | |
| - name: Promote ENSAdmin Vercel Deployment | |
| run: | | |
| chmod +x ./.github/scripts/promote_ensadmin.sh | |
| ./.github/scripts/promote_ensadmin.sh | |
| - name: Send Slack Notification | |
| uses: ./.github/actions/send_slack_notification | |
| with: | |
| slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| slack_title: ${{ env.SLACK_TITLE }} | |
| slack_message: "✅ Switch ENSNode environment completed" |