-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy_nccrd.environment.gov.za.yml
More file actions
118 lines (105 loc) · 3.92 KB
/
deploy_nccrd.environment.gov.za.yml
File metadata and controls
118 lines (105 loc) · 3.92 KB
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
name: Deploy nccrd.environment.gov.za
on:
workflow_dispatch:
push:
tags:
- '*'
env:
IMAGE_NAME: ${{ github.repository }}_stable_node
NGINX_IMAGE_NAME: ${{ github.repository }}_stable_nginx
BRANCH_REF: stable
REGISTRY: ghcr.io
jobs:
build-nginx:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Check out source code (shared)
uses: actions/checkout@master
with:
ref: ${{ env.BRANCH_REF }}
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.NGINX_IMAGE_NAME }}
tags: |
type=sha
- name: Build and push NCCRD
uses: docker/build-push-action@master
with:
context: src/nginx
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-nccrd:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Check out source code (shared)
uses: actions/checkout@master
with:
ref: ${{ env.BRANCH_REF }}
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Build and push
uses: docker/build-push-action@master
with:
context: .
build-args: |
HOSTNAME=https://nccrd.environment.gov.za
DEFAULT_TENANT_ADDRESS=https://nccrd.environment.gov.za
SHOW_DEV_WARNING="false"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: [build-nccrd, build-nginx]
runs-on: saeon
steps:
- name: Check out source code (int)
uses: actions/checkout@master
with:
ref: ${{ env.BRANCH_REF }}
- name: (SCP) Copy Docker files to app server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SWARM_HOSTNAME }}
username: ${{ secrets.SWARM_USERNAME }}
password: ${{ secrets.SWARM_PASSWORD }}
port: ${{ secrets.SWARM_SSH_PORT }}
source: 'deploy/stable/stack.yml'
target: 'nccrd-stable'
- name: (SSH) Deploy Docker stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SWARM_HOSTNAME }}
username: ${{ secrets.SWARM_USERNAME }}
password: ${{ secrets.SWARM_PASSWORD }}
port: ${{ secrets.SWARM_SSH_PORT }}
script: |
echo "ODP_AUTH_CLIENT_SECRET=${{ secrets.ODP_AUTH_CLIENT_SECRET }}" > /home/runner/nccrd-stable/deploy/stable/stack.env
echo "NCCRD_IMAGE=${{ needs.build-nccrd.outputs.image }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env
echo "NGINX_IMAGE=${{ needs.build-nginx.outputs.image }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env
echo "MSSQL_USERNAME=${{ secrets.MSSQL_USERNAME_STABLE }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env
echo "MSSQL_PASSWORD=${{ secrets.MSSQL_PASSWORD_STABLE }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env
sudo /opt/deploy-docker-stack.sh /home/runner/nccrd-stable/deploy/stable/stack.yml /home/runner/nccrd-stable/deploy/stable/stack.env nccrd_stable