File: deliver_data.sh

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

input_file="$1"

if ! [ -f "${input_file}" ] ; then
  echo "You must specify an input file to upload"
  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: ${input_file} (${CI_COMMIT_REF_NAME} - ${CI_COMMIT_SHORT_SHA})"

out_name="${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}"
latest_name="${CI_COMMIT_REF_NAME}_latest"

if ! rclone --config ./ci/rclone.conf copy \
    "${input_file}" \
    "openpaperwork:openpaperwork-download/data/paperwork/${out_name}/" ; then
  echo "rclone failed"
  exit 1
fi

if ! rclone --config ./ci/rclone.conf sync \
    "${input_file}" \
    "openpaperwork:openpaperwork-download/data/paperwork/${latest_name}/" ; then
  echo "rclone failed"
  exit 1
fi

echo Success
exit 0