-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (72 loc) · 2.73 KB
/
deploy-staging.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
name: Deploy
on:
pull_request_target:
types:
- reopened
- opened
- synchronize
jobs:
deploy_staging:
name: Deploy preview
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [ '16.x' ]
os: [ ubuntu-latest ]
steps:
# setup
- name: Checkout out the repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 tlse2021-ci-cd
# frontend
- name: Build and push the frontend image
uses: docker/build-push-action@v2
with:
push: true
context: ./frontend
tags:
ghcr.io/thenativeweb/tlse-frontend:pr-${{ github.event.number }}
build-args: |
"BACKEND_URL=https://api.pr-${{ github.event.number }}.gitops.tlse.thenativeweb.io"
- name: Insert config to manifest
run: 'cat ./deployments/frontend-staging.yaml | envsubst > manifest.yaml'
env:
CONTAINER_REGISTRY_USER: ${{ secrets.GHCR_USER }}
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
PR_NUMBER: ${{ github.event.number }}
- name: Deploy the manifest for the frontend
run: kubectl apply -f ./manifest.yaml
- name: Verify deployment for the frontend
run: kubectl --namespace tlse-pr-${{ github.event.number }} rollout status deployment/tlse-frontend
# backend
- name: Build and push the backend image
uses: docker/build-push-action@v2
with:
push: true
context: ./backend
tags:
ghcr.io/thenativeweb/tlse-backend:pr-${{ github.event.number }}
- name: Insert config to manifest
run: 'cat ./deployments/backend-staging.yaml | envsubst > manifest.yaml'
env:
CONTAINER_REGISTRY_USER: ${{ secrets.GHCR_USER }}
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
PR_NUMBER: ${{ github.event.number }}
- name: Deploy the manifest for the backend
run: kubectl apply -f ./manifest.yaml
- name: Verify deployment for the backend
run: kubectl --namespace tlse-pr-${{ github.event.number }} rollout status deployment/tlse-backend