-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
executable file
·37 lines (33 loc) · 1.1 KB
/
entrypoint.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
#!/bin/bash
set -e
echo "Building some OpenAPI specs for you..."
vertag=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 30)
outputUrls=""
aws_endpoint=$AWS_ENDPOINT
if [ $aws_endpoint != http* ]
then
aws_endpoint=https://$aws_endpoint
fi
files=$1
echo $files
for i in $files
do
outfname=${GITHUB_WORKSPACE}/${i}_${vertag}.html
fname=$(basename $outfname)
npx redoc-cli bundle $GITHUB_WORKSPACE/$i -o $outfname --disableGoogleFont --options.expandDefaultServerVariables "true"
aws --endpoint-url $aws_endpoint s3 cp $outfname s3://$BUCKET_NAME/
aws --endpoint-url $aws_endpoint s3api put-object-acl --bucket $BUCKET_NAME --acl public-read --key $fname
out="== Uploaded spec successfully to https://${BUCKET_NAME}.${AWS_ENDPOINT}/$fname =="
outputUrls+="https://${BUCKET_NAME}.${AWS_ENDPOINT}/$fname "
ln=${#out}
while [ $ln -gt 0 ]; do printf '=%.0s'; ((ln--));done;
echo ""
echo $out
ln=${#out}
while [ $ln -gt 0 ]; do printf '=%.0s'; ((ln--));done;
echo ""
done
# Set the Github Action's output
if [ -n "$outputUrls" ]; then
echo "::set-output name=urls::${outputUrls; ${#outputUrls}-1}"
fi