-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_to_github.sh
executable file
·43 lines (33 loc) · 1.02 KB
/
upload_to_github.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
#!/usr/bin/env bash
set -euo pipefail
BASE_DIR=$(dirname "$0")
if [[ -z ${CARNIVORE_GITHUB_TOKEN:-} ]]; then
echo "CARNIVORE_GITHUB_TOKEN is required" >&2
exit 1
fi
if [[ -z ${CARNIVORE_GITHUB_REPO:-} ]]; then
echo "CARNIVORE_GITHUB_REPO is required" >&2
exit 1
fi
if [[ -z ${CARNIVORE_GITHUB_REPO_DIR:-} ]]; then
echo "CARNIVORE_GITHUB_REPO_DIR is required" >&2
exit 1
fi
# Get the file paths from update_files.sh
file_paths=$("${BASE_DIR}/update_files.sh")
OPTIONAL_ARGS=()
if [ -n "${CARNIVORE_GITHUB_BRANCH:-}" ]; then
OPTIONAL_ARGS+=("--branch" "${CARNIVORE_GITHUB_BRANCH}")
fi
# Iterate over each file path
echo "${file_paths}" | while IFS= read -r file_path; do
file_name=$(basename "${file_path}")
# Upload the file to GitHub
python "${BASE_DIR}/atomic/github_upload.py" \
--file-path "${file_path}" \
--token "${CARNIVORE_GITHUB_TOKEN}" \
--repo "${CARNIVORE_GITHUB_REPO}" \
--repo-path "${CARNIVORE_GITHUB_REPO_DIR}/${file_name}" \
"${OPTIONAL_ARGS[@]}"
rm -f "${file_path}"
done