-
Notifications
You must be signed in to change notification settings - Fork 129
151 lines (131 loc) · 4.65 KB
/
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Deploy
on:
release:
types: [ published ]
workflow_dispatch:
jobs:
# ===== ecs deploy =====
deploy:
name: Deploy to ECS
runs-on: ubuntu-latest
env:
CLUSTER_NAME: avrae
SERVICE_NAME: avrae-bot
DEPLOY_ENV: live
REGION: us-east-1
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: avrae/${{ env.SERVICE_NAME }}
IMAGE_TAG: ${{ github.event.release.tag_name }}
run: |
docker build -t $SERVICE_NAME --build-arg COMMIT=$GITHUB_SHA .
docker tag $SERVICE_NAME $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $SERVICE_NAME $ECR_REGISTRY/$ECR_REPOSITORY:$DEPLOY_ENV
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
echo "IMAGE_NAME=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- name: Download Task Definition
run: |
aws ecs describe-task-definition --task-definition avrae-bot-ecs-task-definition \
--query taskDefinition > task-definition.json
- name: Update Task Definition for new Image Name
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1.2.0
with:
task-definition: task-definition.json
container-name: avrae-bot
image: ${{ steps.build-image.outputs.IMAGE_NAME }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1.4.11
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: avrae-bot
cluster: avrae-live
wait-for-service-stability: true
# ===== help gen =====
build-docs:
name: Build/Upload Help
runs-on: ubuntu-latest
services: # bot instance depends on services
redis: # redis://redis:6379/0
image: redis
ports:
- 6379:6379
mongo: # mongodb://root:topsecret@mongo:27017
image: mongo
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: topsecret
env:
NO_DICECLOUD: 1
DISCORD_OWNER_USER_ID: "98765432109876543"
MONGO_URL: "mongodb://root:topsecret@localhost:27017"
REDIS_URL: "redis://localhost:6379/0"
REGION: us-east-1
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
mkdir shared
- name: Build Help Manifest
run: python scripts/gen_command_json.py -o shared/commands.json test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}
- name: Upload Help Manifest
run: aws s3 cp shared/commands.json s3://media.avrae.io/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --region $REGION
- name: Upload manifest as artifact
uses: actions/upload-artifact@v2
with:
name: help-manifest
path: shared/commands.json
# ===== sentry release =====
sentry:
name: Create Sentry Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: fandom-tabletop
SENTRY_PROJECT: avrae-bot
with:
environment: production
version: ${{ github.event.release.tag_name }}
set_commits: skip