-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (132 loc) · 4.97 KB
/
build-test-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
152
153
154
155
156
157
158
name: Build -> Test -> Deploy
on:
push:
branches:
- master
tags:
- 'prod-*'
schedule:
- cron: '0 6 * * *'
env:
RELEASE_VERSION: ${{ github.sha }}
jobs:
build:
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Image
run: ./scripts/build-release.sh
- name: Authenticate to DO Container Registry
env:
DOCKER_CONFIG: ${{ secrets.DOCKER_CONFIG }}
run: |
mkdir -p $HOME/.docker
echo "${DOCKER_CONFIG}" > $HOME/.docker/config.json
- name: Push Image
run: ./scripts/push-release.sh
test:
needs: [build]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: ./scripts/run-ci.sh
deploy-staging:
needs: [build, test]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
#if: ${{ endsWith(github.ref, 'main') || endsWith(github.ref, '') }}
env:
ENV: staging
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_STAGING }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_STAGING }}
SLACK_CHANNEL: '#connect-bots'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
HOSTNAME: 'cvh-staging'
DOMAIN: 'ameelio.xyz'
ZONE_ID: '16c266b9ad2cc7affc86783eb0fa74fd'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
#- name: Run migrations
# env:
# K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
# SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
# run: ./scripts/deploy-release.sh --apply-migration --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Deploy new version
env:
K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
deploy-prod:
needs: [build, test, deploy-staging]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/prod-') }}
env:
ENV: prod
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_PROD }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_PROD }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_PROD }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: '#infa-info'
HOSTNAME: 'cvh-prod'
DOMAIN: 'ameelio.org'
ZONE_ID: 'c82786df7abd35eb6773c67960fba8d3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
#- name: Run migrations
# env:
# K8S_TOKEN: ${{ secrets.K8S_TOKEN_PROD }}
# SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
# run: ./scripts/deploy-release.sh --apply-migration --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Deploy new version
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
deploy-mcc:
needs: [build, test, deploy-staging]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/prod-') }}
env:
ENV: prod
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_MCC }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_MCC }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_MCC }}
SLACK_CHANNEL: '#infra-info'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
FACILITY: MCC
HOSTNAME: 'cvh-mcc'
DOMAIN: 'ameelio.org'
ZONE_ID: 'c82786df7abd35eb6773c67960fba8d3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
- name: Deploy new version
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug