This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
93 lines (84 loc) · 3.47 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
81
82
83
84
85
86
87
88
89
90
91
92
93
name: run-sqlpackage
description: 'Runs SqlPackage command on a target database'
inputs:
action:
description: 'Action parameter to run with SqlPackage. Supported values are: Publish, DeployReport, DriftReport, Script'
required: true
sourcepath:
description: 'The path where to look for the DACPAC file. If multiple files exists, all of them are processed'
required: true
profile:
description: 'The profile path to use during the execution. It has to be an xml file'
required: true
database-server:
description: 'Database server URL (without protocol). If not indicated in the publishing profile, it has to be indicated here.'
required: false
default: ''
database-name:
description: 'Database name. If not indicated in the publishing profile, it has to be indicated here.'
required: false
default: ''
authtoken:
description: 'The authentication token used to connect to the database, if credentials not indicated in the connection string'
required: false
default: ''
outputpath:
description: 'The output folder where assets will be generated if any'
required: false
default: .
outputfile:
description: 'The output file name. The final name of the file will be [dacpac_name].[outputfile]'
required: false
default: 'deployreport.xml'
runs:
using: "composite"
steps:
- name: Installing SQL Data Tools
shell: bash
run: |
if test -f "/opt/sqlpackage/sqlpackage"; then
echo "::debug::SqlPackage already installed in the context"
else
sudo apt-get install libunwind8
wget -progress=bar:force -q -O sqlpackage.zip \
https://aka.ms/sqlpackage-linux \
&& unzip -qq sqlpackage.zip -d /opt/sqlpackage \
&& chmod a+x /opt/sqlpackage/sqlpackage \
&& rm sqlpackage.zip
fi
- id: sqlpackage
name: Running SqlPackage tool
shell: bash
run: |
echo "::debug::Ensuring target folder '${{ inputs.outputpath }}'"
mkdir -p ${{ inputs.outputpath }}
echo "::debug::Looking for dacpac files at '${{ inputs.sourcepath }}'"
PACKAGE_PATHS=$(find ${{ inputs.sourcepath }} -name '*.dacpac' -exec basename {} \;)
for PACKAGE in $PACKAGE_PATHS
do
echo "::debug::Runing ${{ inputs.action }} on package $PACKAGE"
SQLPACKAGE_CMD="/opt/sqlpackage/sqlpackage \
/Action:${{ inputs.action }} \
/SourceFile:${{ inputs.sourcepath }}/$PACKAGE \
/Profile:${{ inputs.profile }}"
if [[ '${{ inputs.database-server }}' != '' ]]; then
SQLPACKAGE_CMD="$SQLPACKAGE_CMD \
/TargetServerName:${{ inputs.database-server }}"
fi
if [[ '${{ inputs.database-name }}' != '' ]]; then
SQLPACKAGE_CMD="$SQLPACKAGE_CMD \
/TargetDatabaseName:${{ inputs.database-name }}"
fi
if [[ '${{ inputs.authtoken }}' != '' ]]; then
SQLPACKAGE_CMD="$SQLPACKAGE_CMD \
/AccessToken:${{ inputs.authtoken }}"
fi
if [[ '${{ inputs.action }}' != 'Publish' ]]; then
PACKAGE_NAME="${PACKAGE%.*}"
SQLPACKAGE_CMD="$SQLPACKAGE_CMD \
/OutputPath:${{ inputs.outputpath }}/$PACKAGE_NAME.${{ inputs.outputfile }} \
/OverwriteFiles:True"
fi
echo "::debug::SqlPackage intruction is '$SQLPACKAGE_CMD'"
eval $SQLPACKAGE_CMD
done