-
Notifications
You must be signed in to change notification settings - Fork 16
executable file
·92 lines (89 loc) · 4.4 KB
/
deploy.yaml
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
name: Deployment
on:
push:
branches:
- main
- staging
jobs:
build-docker:
name: Build Docker image
environment: ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_CONTAINER_REPO }}/discord-bots:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha
target: prod
deploy:
name: Deploy to Kubernetes
environment: ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: build-docker
env:
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }}
GRAPH_API_KEY: ${{ secrets.GRAPH_API_KEY }}
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }}
WEB3_PROVIDER_ETH_URL: ${{ secrets.WEB3_PROVIDER_ETH_URL }}
WEB3_PROVIDER_POLYGON_URL: ${{ secrets.WEB3_PROVIDER_POLYGON_URL }}
DISCORD_BOT_TOKEN_REBASE: ${{ secrets.DISCORD_BOT_TOKEN_REBASE }}
DISCORD_BOT_WEBHOOK_REBASE: ${{ secrets.DISCORD_BOT_WEBHOOK_REBASE }}
DISCORD_BOT_TOKEN_DAO_FEE: ${{ secrets.DISCORD_BOT_TOKEN_DAO_FEE }}
DISCORD_BOT_TOKEN_DAO_BALANCE: ${{ secrets.DISCORD_BOT_TOKEN_DAO_BALANCE }}
DISCORD_BOT_TOKEN_DCM_SUPPLY: ${{ secrets.DISCORD_BOT_TOKEN_DCM_SUPPLY }}
DISCORD_BOT_TOKEN_KLIMA_BOND_ALERTS: ${{ secrets.DISCORD_BOT_TOKEN_KLIMA_BOND_ALERTS }}
DISCORD_BOT_TOKEN_KLIMA_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_KLIMA_PRICE }}
DISCORD_BOT_TOKEN_BCT_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_BCT_PRICE }}
DISCORD_BOT_TOKEN_MCO2_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_MCO2_PRICE }}
DISCORD_BOT_TOKEN_CCO2_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_CCO2_PRICE }}
DISCORD_BOT_TOKEN_STAKING_REWARDS: ${{ secrets.DISCORD_BOT_TOKEN_STAKING_REWARDS }}
DISCORD_BOT_TOKEN_SUPPLY_CC: ${{ secrets.DISCORD_BOT_TOKEN_SUPPLY_CC }}
DISCORD_BOT_TOKEN_INDEX: ${{ secrets.DISCORD_BOT_TOKEN_INDEX }}
DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO: ${{ secrets.DISCORD_BOT_TOKEN_RETIREMENT_FEE_INFO }}
DISCORD_BOT_TOKEN_TREASURY_CARBON: ${{ secrets.DISCORD_BOT_TOKEN_TREASURY_CARBON }}
DISCORD_BOT_TOKEN_TREASURY_MARKET: ${{ secrets.DISCORD_BOT_TOKEN_TREASURY_MARKET }}
DISCORD_BOT_TOKEN_C3_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_C3_PRICE }}
DISCORD_BOT_TOKEN_UBO_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_UBO_PRICE }}
DISCORD_BOT_TOKEN_MOSS_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_MOSS_PRICE }}
DISCORD_BOT_TOKEN_NBO_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_NBO_PRICE }}
DISCORD_BOT_TOKEN_NCT_PRICE: ${{ secrets.DISCORD_BOT_TOKEN_NCT_PRICE }}
GITHUB_SHA: ${{ github.sha }}
DOCKER_IMAGE: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_CONTAINER_REPO }}/discord-bots:${{ github.sha }}
steps:
- name: Check out source repository
uses: actions/checkout@v2
# TODO update doctl to use 2fcbadcb46efd8dca0d93fbef2a3a8394f5981ba with the error code fix
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# k8s Deployment
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2.1.0-rc
with:
kustomize-version: "4.5.4"
- name: Update deployment file with image
run: sed -i 's|<IMAGE>|'${DOCKER_IMAGE}'|' $GITHUB_WORKSPACE/k8s/base/deployment.yaml
- name: Update secret properties with injected secrets
run: envsubst < $GITHUB_WORKSPACE/k8s/secret.properties.template > $GITHUB_WORKSPACE/k8s/secret.properties
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.DIGITALOCEAN_CLUSTER_NAME }}
- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -k k8s
- name: Verify deployments
run: deploy=$(kubectl get deploy -n discord-bots -o name); for i in $deploy; do kubectl -n discord-bots rollout status $i; done