-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (87 loc) · 3.48 KB
/
loadtest-brazil-client-deploy.yml
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
name: Deploy to Brazil Loadtest Client
on:
workflow_dispatch:
inputs:
release:
type: choice
description: What release to deploy
options:
- arena_load_test
- bot_manager
required: true
target_server:
type: choice
description: Loadtest target server
options:
- loadtest-brazil-server.curseofmirra.com
- loadtest-europe-server.curseofmirra.com
jobs:
build-deploy:
name: Build and deploy to Brazil Loadtest Client
runs-on: ubuntu-latest
environment:
name: testing-brazil
url: https://loadtest-brazil-client.curseofmirra.com/
steps:
- uses: actions/checkout@v4
- name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
- name: Create ssh private key file from env var
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ vars.TS_LOADTEST_CLIENT_HOST }}
run: |
set -ex
mkdir -p ~/.ssh/
sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519
chmod 400 ~/.ssh/id_ed25519
retries=5; until ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done
- name: Copy deploy script
env:
SSH_USERNAME: ${{ vars.SSH_USERNAME }}
SSH_HOST: ${{ vars.TS_LOADTEST_CLIENT_HOST }}
run: |
set -ex
rsync -avz --mkpath devops/deploy.sh ${SSH_USERNAME}@${SSH_HOST}:/home/${SSH_USERNAME}/deploy-script/
- name: Execute deploy script
env:
XDG_RUNTIME_DIR: /run/user/1001 # Temporary fix for systemd commands.
SSH_HOST: ${{ vars.TS_LOADTEST_CLIENT_HOST }}
SSH_USERNAME: ${{ vars.SSH_USERNAME }}
MIX_ENV: ${{ vars.MIX_ENV }}
RELEASE: ${{ inputs.release }}
TARGET_SERVER: ${{ inputs.target_server }}
LOADTEST_EUROPE_HOST: ${{ vars.LOADTEST_EUROPE_HOST }}
LOADTEST_BRAZIL_HOST: ${{ vars.LOADTEST_BRAZIL_HOST }}
PHX_SERVER: ${{ vars.PHX_SERVER }}
PHX_HOST: ${{ vars.LOADTEST_CLIENT_HOST }}
PORT: ${{ vars.ARENA_PORT }}
BOT_MANAGER_PORT: ${{ vars.BOT_MANAGER_PORT }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME_LOADTEST }}
NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
set -ex
ssh ${SSH_USERNAME}@${SSH_HOST} \
XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} \
BRANCH_NAME=${BRANCH_NAME} \
MIX_ENV=${MIX_ENV} \
RELEASE=${RELEASE} \
TARGET_SERVER=${TARGET_SERVER} \
LOADTEST_EUROPE_HOST=${LOADTEST_EUROPE_HOST} \
LOADTEST_BRAZIL_HOST=${LOADTEST_BRAZIL_HOST} \
PHX_SERVER=${PHX_SERVER} \
PHX_HOST=${PHX_HOST} \
PORT=${PORT} \
BOT_MANAGER_PORT=${BOT_MANAGER_PORT} \
DATABASE_URL=${DATABASE_URL} \
SECRET_KEY_BASE=${SECRET_KEY_BASE} \
NEWRELIC_APP_NAME=${NEWRELIC_APP_NAME} \
NEWRELIC_KEY=${NEWRELIC_KEY} \
/home/${SSH_USERNAME}/deploy-script/deploy.sh