-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
133 lines (127 loc) · 4.37 KB
/
action.yml
File metadata and controls
133 lines (127 loc) · 4.37 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: 'Synchronize two drupal instances'
description: 'Assumes Github Secrets for nextcloud are set up'
inputs:
target_ssh_user:
description: 'Destination SSH user account'
required: true
target_ssh_host:
description: 'Destination SSH host server'
required: true
target_ssh_key:
description: 'Destination SSH private key'
required: true
ssh_user_jumphost:
description: 'SSH user account for jumphost'
required: false
default: ''
ssh_host_jumphost:
description: 'SSH host server for jumphost'
required: false
default: ''
target_project_dir:
description: 'Absolute path where the project root is configured (where live symlink exists)'
required: true
sync_db:
description: 'Sync SQL database'
default: true
# sync_files:
# description: 'Sync "files" archive'
# default: false
nextcloud_user:
description: 'Nextcloud username for sync'
required: false
default: ''
nextcloud_app_password:
description: 'Nextcloud app password for sync'
required: false
default: ''
nextcloud_path:
description: 'Project folder path in Nextcloud'
required: false
default: ''
nextcloud_base_url:
description: 'Nextcloud base URL'
required: false
default: 'https://drive.eaudeweb.ro'
runs:
using: "composite"
steps:
- name: 'Configure SSH'
if: ${{ inputs.ssh_host_jumphost == '' }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/server.key
chmod 600 ~/.ssh/server.key
cat > ~/.ssh/config <<END
Host server
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/server.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ inputs.target_ssh_user }}
SSH_HOST: ${{ inputs.target_ssh_host }}
SSH_KEY: ${{ inputs.target_ssh_key }}
shell: bash
- name: 'Configure SSH'
if: ${{ inputs.ssh_host_jumphost != '' }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/server.key
chmod 600 ~/.ssh/server.key
cat > ~/.ssh/config <<END
Host jumphost
HostName $SSH_HOST_JUMPHOST
User $SSH_USER_JUMPHOST
IdentityFile ~/.ssh/server.key
StrictHostKeyChecking no
LogLevel QUIET
Host server
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/server.key
StrictHostKeyChecking no
ProxyJump jumphost
END
env:
SSH_USER: ${{ inputs.target_ssh_user }}
SSH_HOST: ${{ inputs.target_ssh_host }}
SSH_KEY: ${{ inputs.target_ssh_key }}
SSH_USER_JUMPHOST: ${{ inputs.ssh_user_jumphost }}
SSH_HOST_JUMPHOST: ${{ inputs.ssh_host_jumphost }}
shell: bash
- name: 'Synchronize database from source to target'
if: ${{ inputs.sync_db == 'true' }}
run: |
SOURCE_URL="${NEXTCLOUD_BASE_URL}/remote.php/dav/files/${NEXTCLOUD_USER}/${NEXTCLOUD_PATH}/mysql/database.sql.gz"
ssh server "
cd ${{ inputs.target_project_dir }} &&
./vendor/bin/robo sql:sync \
-D sites.default.sync.username=\"${NEXTCLOUD_USER}\" \
-D sites.default.sync.password=\"${NEXTCLOUD_APP_PASSWORD}\" \
-D sites.default.sql.sync.source=\"${SOURCE_URL}\"
"
env:
NEXTCLOUD_USER: ${{ inputs.nextcloud_user }}
NEXTCLOUD_APP_PASSWORD: ${{ inputs.nextcloud_app_password }}
NEXTCLOUD_PATH: ${{ inputs.nextcloud_path }}
NEXTCLOUD_BASE_URL: ${{ inputs.nextcloud_base_url }}
shell: bash
# - name: 'Synchronize files archive'
# if: ${{ inputs.sync_files == 'true' }}
# run: |
# SOURCE_URL="${NEXTCLOUD_BASE_URL}/remote.php/dav/files/${NEXTCLOUD_USER}/${NEXTCLOUD_PATH}/files.tar.gz"
# ssh server "
# cd ${{ inputs.target_project_dir }} &&
# ./vendor/bin/robo files:sync \
# -D sites.default.sync.username=\"${NEXTCLOUD_USER}\" \
# -D sites.default.sync.password=\"${NEXTCLOUD_PASSWORD}\" \
# -D sites.default.files.sync.source=\"${SOURCE_URL}\"
# "
# env:
# NEXTCLOUD_USER: ${{ inputs.nextcloud_user }}
# NEXTCLOUD_PASSWORD: ${{ inputs.nextcloud_password }}
# NEXTCLOUD_PATH: ${{ inputs.nextcloud_path }}
# NEXTCLOUD_BASE_URL: ${{ inputs.nextcloud_base_url }}
# shell: bash