-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (103 loc) · 3.9 KB
/
deploy_nccrd.saeon.ac.za.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
name: Deploy nccrd.saeon.ac.za
on:
workflow_dispatch:
env:
NCCRD_IMAGE_NAME: ${{ github.repository }}_next_node
NGINX_IMAGE_NAME: ${{ github.repository }}_next_nginx
REGISTRY: ghcr.io
BRANCH_REF: next
jobs:
build-nginx:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout source code
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.NCCRD_IMAGE_NAME }}
tags: |
type=sha
- name: Build and push NCCRD
uses: docker/build-push-action@master
with:
context: .
build-args: |
HOSTNAME=https://nccrd.saeon.ac.za
DEFAULT_TENANT_ADDRESS=https://nccrd.saeon.ac.za
DEFAULT_NOTICES="This is the DEVELOPMENT deployment,warn"
SHOW_DEV_WARNING="true"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: [build-nginx, build-nccrd]
runs-on: saeon
steps:
- name: Checkout source code
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/next/stack.yml'
target: 'nccrd-next'
- 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 "MSSQL_PASSWORD=${{ secrets.MSSQL_PASSWORD_NEXT }}" > /home/runner/nccrd-next/deploy/next/stack.env
echo "MSSQL_USERNAME=${{ secrets.MSSQL_USERNAME_NEXT }}" >> /home/runner/nccrd-next/deploy/next/stack.env
echo "NCCRD_IMAGE=${{ needs.build-nccrd.outputs.image }}" >> /home/runner/nccrd-next/deploy/next/stack.env
echo "NGINX_IMAGE=${{ needs.build-nginx.outputs.image }}" >> /home/runner/nccrd-next/deploy/next/stack.env
echo "ODP_AUTH_CLIENT_SECRET=${{ secrets.ODP_AUTH_CLIENT_SECRET }}" >> /home/runner/nccrd-next/deploy/next/stack.env
sudo /opt/deploy-docker-stack.sh /home/runner/nccrd-next/deploy/next/stack.yml /home/runner/nccrd-next/deploy/next/stack.env nccrd_next