-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdeploy_switch_ensnode_environment.yml
More file actions
105 lines (85 loc) · 5.09 KB
/
deploy_switch_ensnode_environment.yml
File metadata and controls
105 lines (85 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: "Deploy: Switch ENSNode Environment"
permissions:
contents: read
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@v6
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"
# V2-SEPOLIA
redis-cli -u $REDIS_URL SET traefik/http/routers/v2-sepolia-api-router/service "${TARGET_ENVIRONMENT}-v2-sepolia-api"
redis-cli -u $REDIS_URL SET traefik/http/routers/v2-sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-v2-sepolia-indexer"
redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-v2-sepolia-api-router/service "${TARGET_ENVIRONMENT}-v2-sepolia-api"
redis-cli -u $REDIS_URL SET traefik/http/routers/lb-header-v2-sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-v2-sepolia-indexer"
# SEPOLIA
redis-cli -u $REDIS_URL SET traefik/http/routers/sepolia-api-router/service "${TARGET_ENVIRONMENT}-sepolia-api"
redis-cli -u $REDIS_URL SET traefik/http/routers/sepolia-indexer-router/service "${TARGET_ENVIRONMENT}-sepolia-indexer"
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"
# ENSRAINBOW SEARCHLIGHT
redis-cli -u $REDIS_URL SET traefik/http/routers/ensrainbow-searchlight-api-router/service "${TARGET_ENVIRONMENT}-ensrainbow-searchlight-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"