-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
68 lines (66 loc) · 2.39 KB
/
action.yaml
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
name: mysql-schema-diff
author: Sean Burke
description: Check to see if the MySQL schemas for 2 DBs are the same
branding:
icon: 'database'
color: 'purple'
inputs:
hostname1:
description: 'The host of the first mysql connection'
required: false
default: 'localhost'
username1:
description: 'The username of the first mysql connection'
required: true
password1:
description: 'The password of the first mysql connection'
required: false
default: ''
database1:
description: 'The database name of the first mysql connection'
required: true
hostname2:
description: 'The host of the second mysql connection'
required: false
default: 'localhost'
username2:
description: 'The username of the second mysql connection'
required: true
password2:
description: 'The password of the second mysql connection'
required: false
default: ''
database2:
description: 'The database name of the first mysql connection'
required: true
runs:
using: "composite"
steps:
- name: MySQL Diff
shell: bash
run: |
user1=${{ inputs.username1 }};
host1=${{ inputs.hostname1 }};
pwd1=${{ inputs.password1 }};
db1=${{ inputs.database1 }};
echo "Connecting to DB1"
mysqldump --defaults-extra-file=<(printf '[client]\nuser = %s\npassword = %s\nhost = %s' $user1 $pwd1 $host1) -d --skip-add-drop-table --skip-add-drop-database $db1 | sed -e 's/AUTO_INCREMENT=[[:digit:]]* //' | sed -e 's/Host: .* //' | sed -e 's/-- Dump completed on .*//' > db1.sql
if [[ $? -ne 0 ]]; then
echo >&2 "SQL error"
exit 1
fi
echo "db1.sql created"
# Use details to connect to dev and mysqldump the tables without data
user2=${{ inputs.username2 }}
host2=${{ inputs.hostname2 }}
pwd2=${{ inputs.password2 }}
db2=${{ inputs.database2 }}
echo "Connecting to DB2"
mysqldump --defaults-extra-file=<(printf '[client]\nuser = %s\npassword = %s\nhost = %s' $user2 $pwd2 $host2) -d --skip-add-drop-table --skip-add-drop-database $db2 | sed -e 's/AUTO_INCREMENT=[[:digit:]]* //' | sed -e 's/Host: .* //' | sed -e 's/-- Dump completed on .*//' > db2.sql
if [[ $? -ne 0 ]]; then
echo >&2 "SQL error"
exit 1
fi
echo "Checking for differences"
diff db1.sql db2.sql
echo "Completed"