-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
80 lines (77 loc) · 2.37 KB
/
action.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
name: 'Dump SQL database'
description: 'Connect to server and create an SQL dump to retrieve'
inputs:
ssh_user:
description: 'SSH user account'
required: true
ssh_host:
description: 'SSH host server'
required: true
ssh_key:
description: '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: ''
project_dir:
description: 'Absolute path to the Drupal home directory (where web folder is located)'
required: true
sql_dump_file:
description: 'Absolute path to the SQL dump file (without .gz extension)'
required: true
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.ssh_user }}
SSH_HOST: ${{ inputs.ssh_host }}
SSH_KEY: ${{ inputs.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.ssh_user }}
SSH_HOST: ${{ inputs.ssh_host }}
SSH_KEY: ${{ inputs.ssh_key }}
SSH_USER_JUMPHOST: ${{ inputs.ssh_user_jumphost }}
SSH_HOST_JUMPHOST: ${{ inputs.ssh_host_jumphost }}
shell: bash
- name: 'Dump SQL database'
run: ssh server 'cd ${{ inputs.project_dir }} && ./vendor/bin/drush sql:dump --extra-dump=--no-tablespaces --result-file ${{ inputs.sql_dump_file }} --gzip'
shell: bash