-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathentrypoint.sh
80 lines (56 loc) · 1.76 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
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
76
77
78
79
80
#!/bin/bash
set -e
source /gh-toolkit/shell.sh
gh_log ""
CONFIRM_AND_PUSH=$(gh_input "CONFIRM_AND_PUSH")
COMMITTER_NAME=$(gh_input "COMMITTER_NAME")
COMMITTER_EMAIL=$(gh_input "COMMITTER_EMAIL")
gitconfig "$COMMITTER_NAME" "$COMMITTER_EMAIL"
gh_validate_input "FILES" "FILES List is required"
mkdir -p /dynamic-readme-tmp/repos/
if [ -z "$GITHUB_TOKEN" ]; then
gh_log_error "🚩 Set the GITHUB_TOKEN env variable"
fi
if [ -z "$REPOSITORY_SLUG" ]; then
gh_log "ℹ︎ Please Use https://github.com/varunsridharan/action-repository-meta Action to expose useful variables"
fi
RAW_FILES=$(gh_input "FILES")
FILES=($RAW_FILES)
GIT_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
php /dynamic-readme/global-repo.php
gh_log ""
for FILE in "${FILES[@]}"; do
FILE=($(echo $FILE | tr "=" "\n"))
SRC_FILE=${FILE[0]}
gh_log_group_start "📓 ${SRC_FILE}"
if [ ${FILE[1]+yes} ]; then
DEST_FILE="${FILE[1]}"
else
DEST_FILE="${SRC_FILE}"
fi
DEST_FOLDER_PATH=$(dirname "${GITHUB_WORKSPACE}/${DEST_FILE}")
if [ ! -d "$DEST_FOLDER_PATH" ]; then
gh_log " Creating [$DEST_FOLDER_PATH]"
mkdir -p $DEST_FOLDER_PATH
fi
gh_log "SRC_FILE : ${SRC_FILE}"
gh_log "DEST_FILE : ${DEST_FILE}"
php /dynamic-readme/app.php "${SRC_FILE}" "${DEST_FILE}"
gh_log ""
if [ "$CONFIRM_AND_PUSH" == true ]; then
gh_log "🚀 Confirm and push is the strategy used"
git add "${GITHUB_WORKSPACE}/${DEST_FILE}" -f
if [ "$(git status --porcelain)" != "" ]; then
COMMIT_MESSAGE=$(gh_input "COMMIT_MESSAGE")
git commit -m "$COMMIT_MESSAGE"
else
gh_log " ✅ No Changes Are Done : ${SRC_FILE}"
fi
fi
gh_log_group_end
done
gh_log ""
if [ "$CONFIRM_AND_PUSH" == true ]; then
git push $GIT_URL
fi
gh_log ""