-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (134 loc) · 6.79 KB
/
deploy_docker.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
name: Deploy Docker Image
on:
workflow_call:
inputs:
environment:
required: true
type: string
server_image_tag:
default: "latest"
type: string
client_image_tag:
default: "latest"
type: string
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
url: '${{ vars.CLIENT_HOST }}'
steps:
- name: SSH to VM and Execute Docker-Compose Down
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f docker-compose.prod.yml --env-file=.env.prod down --remove-orphans --rmi all
- name: Checkout Code
uses: actions/checkout@v4
- name: Create main.cf and master.cf File
run: |
echo "${{ vars.POSTFIX_MAIN_CF }}" > main.cf
echo "${{ vars.POSTFIX_MASTER_CF }}" > master.cf
- name: Copy Docker Compose File From Repo to VM Host
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "./docker-compose.prod.yml"
target: /home/${{ vars.VM_USERNAME }}
- name: Copy main.cf to VM Host
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "main.cf"
target: /home/${{ vars.VM_USERNAME }}/postfix-config/
- name: Copy master.cf to VM Host
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "master.cf"
target: /home/${{ vars.VM_USERNAME }}/postfix-config/
- name: SSH to VM and Create .env.prod
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
rm .env.prod
touch .env.prod
echo "SPRING_DATASOURCE_DATABASE=${{ vars.SPRING_DATASOURCE_DATABASE }}" >> .env.prod
echo "SPRING_DATASOURCE_USERNAME=${{ vars.SPRING_DATASOURCE_USERNAME }}" >> .env.prod
echo "SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }}" >> .env.prod
echo "APP_HOSTNAME=${{ vars.APP_HOSTNAME }}" >> .env.prod
echo "SERVER_HOST=${{ vars.SERVER_HOST }}" >> .env.prod
echo "CLIENT_HOST=${{ vars.CLIENT_HOST }}" >> .env.prod
echo "APPLICATION_TITLE=${{ vars.APPLICATION_TITLE }}" >> .env.prod
echo "CHAIR_NAME=${{ vars.CHAIR_NAME }}" >> .env.prod
echo "CHAIR_URL=${{ vars.CHAIR_URL }}" >> .env.prod
echo "DEFAULT_SUPERVISOR_UUID=${{ vars.DEFAULT_SUPERVISOR_UUID }}" >> .env.prod
echo "ALLOW_SUGGESTED_TOPICS=${{ vars.ALLOW_SUGGESTED_TOPICS }}" >> .env.prod
echo "THESIS_TYPES=${{ vars.THESIS_TYPES }}" >> .env.prod
echo "STUDY_PROGRAMS=${{ vars.STUDY_PROGRAMS }}" >> .env.prod
echo "STUDY_DEGREES=${{ vars.STUDY_DEGREES }}" >> .env.prod
echo "GENDERS=${{ vars.GENDERS }}" >> .env.prod
echo "LANGUAGES=${{ vars.LANGUAGES }}" >> .env.prod
echo "CUSTOM_DATA=${{ vars.CUSTOM_DATA }}" >> .env.prod
echo "THESIS_FILES=${{ vars.THESIS_FILES }}" >> .env.prod
echo "SCIENTIFIC_WRITING_GUIDE=${{ vars.SCIENTIFIC_WRITING_GUIDE }}" >> .env.prod
echo "MAIL_SENDER=${{ vars.MAIL_SENDER }}" >> .env.prod
echo "MAIL_SIGNATURE=${{ vars.MAIL_SIGNATURE }}" >> .env.prod
echo "MAIL_BCC_RECIPIENTS=${{ vars.MAIL_BCC_RECIPIENTS }}" >> .env.prod
echo "MAIL_WORKSPACE_URL=${{ vars.MAIL_WORKSPACE_URL }}" >> .env.prod
echo "KEYCLOAK_HOST=${{ vars.KEYCLOAK_HOST }}" >> .env.prod
echo "KEYCLOAK_REALM_NAME=${{ vars.KEYCLOAK_REALM_NAME }}" >> .env.prod
echo "KEYCLOAK_CLIENT_ID=${{ vars.KEYCLOAK_CLIENT_ID }}" >> .env.prod
echo "KEYCLOAK_SERVICE_CLIENT_ID=${{ vars.KEYCLOAK_SERVICE_CLIENT_ID }}" >> .env.prod
echo "KEYCLOAK_SERVICE_CLIENT_SECRET=${{ secrets.KEYCLOAK_SERVICE_CLIENT_SECRET }}" >> .env.prod
echo "KEYCLOAK_SERVICE_STUDENT_GROUP_NAME=${{ vars.KEYCLOAK_SERVICE_STUDENT_GROUP_NAME }}" >> .env.prod
echo "CALDAV_ENABLED=${{ vars.CALDAV_ENABLED }}" >> .env.prod
echo "CALDAV_URL=${{ vars.CALDAV_URL }}" >> .env.prod
echo "CALDAV_USERNAME=${{ vars.CALDAV_USERNAME }}" >> .env.prod
echo "CALDAV_PASSWORD=${{ secrets.CALDAV_PASSWORD }}" >> .env.prod
echo "SERVER_IMAGE_TAG=${{ inputs.server_image_tag }}" >> .env.prod
echo "CLIENT_IMAGE_TAG=${{ inputs.client_image_tag }}" >> .env.prod
- name: SSH to VM and Execute Docker-Compose Up
uses: appleboy/[email protected]
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
docker compose -f docker-compose.prod.yml --env-file=.env.prod up --pull=always -d