-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.14 KB
/
deploy-stage.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
name: Build App
on:
push:
branches: [stage]
workflow_dispatch:
inputs:
comment:
description: Comment on triggering this workflow
required: false
jobs:
build:
name: Build App (Stage)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Log into Harbor Registry
uses: docker/login-action@v1
with:
registry: harbor.disembark.dev
username: robot$deploy-7tv
password: ${{ secrets.REGISTRY_TOKEN }}
- uses: docker/setup-buildx-action@v1
id: buildx
with:
install: true
- name: Build Image
id: build_step
uses: docker/build-push-action@v2
with:
build-args: |
stage=1
push: true
tags: |
harbor.disembark.dev/7tv-stage/webapp:${{ github.sha }}
harbor.disembark.dev/7tv-stage/webapp:latest
deploy:
name: Deploy App (Stage)
runs-on: ubuntu-latest
needs: # Run this after build
- build
steps:
# Checkout repository
- uses: actions/checkout@v2
# Clone k8s repository
- uses: actions/checkout@v2
with:
repository: SevenTV/k8s
path: k8s
token: ${{ secrets.SERVICE_PAT }}
# Deploy to k8s
- name: Install kubectl&
uses: azure/setup-kubectl@v1
- name: Apply Deployment & Rollout
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBECONFIG_STAGE }}
KUBE_RESOURCE: deploy
KUBE_IMAGE_PATCH: >-
[
{ "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "harbor.disembark.dev/7tv-stage/webapp:${{ github.sha }}" }
]
run: |
mkdir -p ~/.kube
(echo $KUBE_CONFIG_DATA | base64 -d) >> ~/.kube/config
kubectl config use-context autodeploy@SevenTV
kubectl apply -f k8s/cluster/7tv-stage/webapp-angular.yaml
kubectl patch $KUBE_RESOURCE seventv-webapp --type="json" -p="$KUBE_IMAGE_PATCH"
kubectl rollout restart $KUBE_RESOURCE/seventv-webapp