-
-
Notifications
You must be signed in to change notification settings - Fork 3
153 lines (143 loc) · 6.14 KB
/
deploy-production.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
---
name: Build & Deploy Production
on:
push:
branches: [master]
jobs:
build-docker-images:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [20]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set current date as env variable
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Set Short SHA variable
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Get Latest tag
id: latesttag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 'UNKNOWN' # Optional fallback tag to use when no tag can be found
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push production image
uses: docker/build-push-action@v3
with:
file: provisioning/production/Dockerfile
platforms: linux/amd64
push: true
tags: |
maelstromeous/ps2alerts:aggregator-production-${{ github.sha }}
maelstromeous/ps2alerts:aggregator-production-latest
build-args: |
BUILD_SHA=${{ env.SHORT_SHA }}
BUILT=${{ env.NOW }}
VERSION=${{ steps.latesttag.outputs.tag }}
# deploy-to-k8s:
# needs: build-docker-images
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# submodules: true
#
# # Create copies of the template for different aggregator census environments
# - name: Copy Templates
# working-directory: provisioning/k8s
# env:
# FILES: application-pc.yml application-ps4eu.yml application-ps4us.yml
# run: for f in $FILES; do cp application-template.yml $f; done
#
# # Inject the application template with the correct variables. {{ version }} refers to the Git SHA and is what changes the container version.
# - name: Update the K8s application resource file (PC)
# run: |
# sed -is -e 's|{{ application }}|ps2alerts-aggregator-pc|' \
# -e 's|{{ environment }}|production|' \
# -e 's|{{ version }}|${{ github.sha }}|' \
# -e 's|{{ port }}|3000|' \
# -e 's|{{ census_service_id }}|${{ secrets.CENSUS_SERVICE_ID }}|' \
# -e 's|{{ census_environment }}|ps2|' \
# -e 's|{{ rabbitmq_pass }}|${{ secrets.RABBITMQ_PS2ALERTS_PASS }}|' \
# -e 's|{{ redis_host }}|ps2alerts-redis-master|' \
# -e 's|{{ redis_pass }}|${{ secrets.REDIS_PASS }}|' \
# -e 's|{{ redis_db }}|1|' \
# -e 's|{{ internal_api_user }}|${{ secrets.INTERNAL_API_USER }}|' \
# -e 's|{{ internal_api_pass }}|${{ secrets.INTERNAL_API_PASS }}|' \
# -e 's|{{ request_cpu }}|800m|' \
# -e 's|{{ request_mem }}|0.25Gi|' \
# -e 's|{{ limit_cpu }}|1600m|' \
# -e 's|{{ limit_mem }}|0.5Gi|' \
# provisioning/k8s/application-pc.yml
#
# - name: Update the K8s application resource file (PS4EU)
# run: |
# sed -is -e 's|{{ application }}|ps2alerts-aggregator-ps4eu|' \
# -e 's|{{ environment }}|production|' \
# -e 's|{{ version }}|${{ github.sha }}|' \
# -e 's|{{ port }}|3000|' \
# -e 's|{{ census_service_id }}|${{ secrets.CENSUS_SERVICE_ID }}|' \
# -e 's|{{ census_environment }}|ps2ps4eu|' \
# -e 's|{{ rabbitmq_pass }}|${{ secrets.RABBITMQ_PS2ALERTS_PASS }}|' \
# -e 's|{{ redis_host }}|ps2alerts-redis-master|' \
# -e 's|{{ redis_pass }}|${{ secrets.REDIS_PASS }}|' \
# -e 's|{{ redis_db }}|1|' \
# -e 's|{{ internal_api_user }}|${{ secrets.INTERNAL_API_USER }}|' \
# -e 's|{{ internal_api_pass }}|${{ secrets.INTERNAL_API_PASS }}|' \
# -e 's|{{ request_cpu }}|100m|' \
# -e 's|{{ request_mem }}|0.15Gi|' \
# -e 's|{{ limit_cpu }}|400m|' \
# -e 's|{{ limit_mem }}|0.25Gi|' \
# provisioning/k8s/application-ps4eu.yml
#
# - name: Update the K8s application resource file (PS4US)
# run: |
# sed -is -e 's|{{ application }}|ps2alerts-aggregator-ps4us|' \
# -e 's|{{ environment }}|production|' \
# -e 's|{{ version }}|${{ github.sha }}|' \
# -e 's|{{ port }}|3000|' \
# -e 's|{{ census_service_id }}|${{ secrets.CENSUS_SERVICE_ID }}|' \
# -e 's|{{ census_environment }}|ps2ps4us|' \
# -e 's|{{ rabbitmq_pass }}|${{ secrets.RABBITMQ_PS2ALERTS_PASS }}|' \
# -e 's|{{ redis_host }}|ps2alerts-redis-master|' \
# -e 's|{{ redis_pass }}|${{ secrets.REDIS_PASS }}|' \
# -e 's|{{ redis_db }}|1|' \
# -e 's|{{ internal_api_user }}|${{ secrets.INTERNAL_API_USER }}|' \
# -e 's|{{ internal_api_pass }}|${{ secrets.INTERNAL_API_PASS }}|' \
# -e 's|{{ request_cpu }}|150m|' \
# -e 's|{{ request_mem }}|0.15Gi|' \
# -e 's|{{ limit_cpu }}|450m|' \
# -e 's|{{ limit_mem }}|0.25Gi|' \
# provisioning/k8s/application-ps4us.yml
#
# # Apply the application resources, telling k8s to change the container version to the new one.
# - uses: actions-hub/kubectl@master
# name: Apply application resources
# env:
# KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
# with:
# args: apply -f provisioning/k8s/application-pc.yml -f provisioning/k8s/application-ps4eu.yml -f provisioning/k8s/application-ps4us.yml
#
# # Outputs the rollout status and returns a 0 signal (thus completing the workflow) once it's rolled out.
# - uses: actions-hub/kubectl@master
# name: Wait for deployment to finish
# env:
# KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
# with:
# args: rollout status deployment/ps2alerts-aggregator-pc-production -n ps2alerts