File: deliver_doc.sh

package info (click to toggle)
paperwork 2.2.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 166,664 kB
  • sloc: python: 44,775; makefile: 992; sh: 625; xml: 135
file content (41 lines) | stat: -rwxr-xr-x 938 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

directory="$1"
destination="$2"

if ! [ -d "${directory}" ] || [ -z "${destination}" ] ; then
  echo "You must specify a directory to upload and a destination directory"
  exit 1
fi

if [ -z "$RCLONE_CONFIG_OPENPAPERWORK_ACCESS_KEY_ID" ] ; then
  echo "Delivery: No rclone credentials provided."
  exit 0
fi

if ! which rclone; then
  echo "rclone not available."
  exit 1
fi

echo "Delivering: ${directory} (${CI_COMMIT_REF_NAME} - ${CI_COMMIT_SHORT_SHA})"

out_name="$(date "+%Y%m%d_%H%M%S")_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
latest_name="latest"

if ! rclone --config ./ci/rclone.conf copy \
    "${directory}/" \
    "openpaperwork:openpaperwork-doc/${destination}/${out_name}" ; then
  echo "rclone failed"
  exit 1
fi

if ! rclone --config ./ci/rclone.conf sync \
    "${directory}/" \
    "openpaperwork:openpaperwork-doc/${destination}/latest" ; then
  echo "rclone failed"
  exit 1
fi

echo Success
exit 0