-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.sh
executable file
·75 lines (63 loc) · 1.91 KB
/
main.sh
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
#!/bin/bash
set -eo pipefail
while getopts a:b:c:d:e:f:g:h:i flag
do
case "${flag}" in
a) publisher=${OPTARG};;
b) credentials=${OPTARG};;
c) bucket=${OPTARG};;
d) entity=${OPTARG};;
e) sourceDir=${OPTARG};;
f) azureAccountName=${OPTARG};;
g) azureAccountKey=${OPTARG};;
h) awsRoleArn=${OPTARG};;
i) awsEndpoint=${OPTARG};;
esac
done
pushd $GITHUB_WORKSPACE
if [[ ! -d $sourceDir ]]
then
echo "$sourceDir does not exist"
exit 0
fi
echo "Generating the docs from $sourceDir to $sourceDir/site/"
techdocs-cli generate --no-docker --verbose --source-dir "$sourceDir" --output-dir "$sourceDir/site"
if [[ $publisher == "googleGcs" ]]; then
echo $credentials | base64 -d > /tmp/credentials
echo "Publishing $entity to $publisher"
GOOGLE_APPLICATION_CREDENTIALS=/tmp/credentials techdocs-cli publish \
--publisher-type $publisher \
--storage-name $bucket \
--entity $entity \
--directory "$sourceDir/site"
exit 0
fi
creds=( $credentials )
if [[ $publisher == "awsS3" ]]; then
AWS_ACCESS_KEY_ID=${creds[0]}
AWS_SECRET_ACCESS_KEY=${creds[1]}
AWS_REGION=${creds[2]}
echo "Publishing $entity to $publisher"
techdocs-cli publish \
--publisher-type $publisher \
--storage-name $bucket \
--entity $entity \
--awsRoleArn $awsRoleArn \
--awsEndpoint $awsEndpoint \
--directory "$sourceDir/site"
fi
if [[ $publisher == "azureBlobStorage" ]]; then
AZURE_TENANT_ID=${creds[0]}
AZURE_CLIENT_ID=${creds[1]}
AZURE_CLIENT_SECRET=${creds[2]}
techdocs-cli publish \
--publisher-type $publisher \
--storage-name $bucket \
--entity $entity \
--azureAccountName $azureAccountName \
--azureAccountKey $azureAccountKey \
--directory "$sourceDir/site"
exit 0
fi
echo "Publisher $publisher not valid"
exit 1