-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
executable file
·127 lines (101 loc) · 3.4 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
set -e
echo $PWD
ls
# Ensure the jobfile exists
if [[ ! -f "${INPUT_FILENAME}" ]]; then
printf "${INPUT_FILENAME} does not exist.\n"
exit 1
fi
# If we are verbatim given a previous filename, use it
if [ ! -z ${INPUT_PREVIOUS_FILENAME} ]; then
JOBFILE="${INPUT_PREVIOUS_FILENAME}"
else
# Wget the comparison file
PARENT_SHA=$(git log --pretty=%P -n 1 ${CURRENT_SHA} | cut -d ' ' -f 1)
JOBFILE="https://raw.githubusercontent.com/${INPUT_REPO}/${PARENT_SHA}/${INPUT_FILENAME}"
TMP=$(mktemp -d)
BASENAME=$(basename ${INPUT_FILENAME})
wget ${JOBFILE} -O "${TMP}/${BASENAME}"
if [[ "$?" != "0" ]]; then
printf "Issue getting previous job file ${JOBFILE}\n"
exit 1
fi
JOBFILE="${TMP}/${BASENAME}"
if [[ ! -f "${JOBFILE}" ]]; then
printf "${JOBFILE} does not exist.\n"
exit 1
fi
fi
# Are we globally deploying?
DEPLOY=true
if [[ "${INPUT_DEPLOY}" == "false" ]]; then
DEPLOY=false
fi
# Do not deploy ever on test
if [[ "${INPUT_TEST}" == "true" ]]; then
printf "🚧️ This is a test run! Deploy set to false 🚧️\n"
DEPLOY=false
fi
DEPLOY_BLUESKY=false
if [ ! -z ${BLUESKY_EMAIL+x} ] && [ ! -z ${BLUESKY_PASSWORD+x} ] && [[ "${BLUESKY_DEPLOY}" == "true" ]]; then
DEPLOY_BLUESKY=true
fi
# If everything not unset and deploy twitter is true, we deploy!
DEPLOY_TWITTER=false
if [ ! -z ${TWITTER_API_KEY+x} ] && [ ! -z ${TWITTER_API_SECRET+x} ] && [ ! -z ${TWITTER_CONSUMER_KEY+x} ] && [ ! -z ${TWITTER_CONSUMER_SECRET+x} ] && [[ "${TWITTER_DEPLOY}" == "true" ]]; then
DEPLOY_TWITTER=true
fi
# Likewise for mastodon
DEPLOY_MASTODON=false
if [ ! -z ${MASTODON_ACCESS_TOKEN+x} ] && [ ! -z ${MASTODON_API_BASE_URL+x} ] && [[ "${MASTODON_DEPLOY}" == "true" ]]; then
DEPLOY_MASTODON=true
fi
# And Slack
DEPLOY_SLACK=false
if [ ! -z ${SLACK_WEBHOOK+x} ] && [[ "${SLACK_DEPLOY}" == "true" ]]; then
DEPLOY_SLACK=true
fi
# And Discord
DEPLOY_DISCORD=false
if [ ! -z ${DISCORD_WEBHOOK+x} ] && [[ "${DISCORD_DEPLOY}" == "true" ]]; then
DEPLOY_DISCORD=true
fi
# Alert the user everything that will happen
printf " Global Deploy: ${DEPLOY}\n"
printf "Deploy Mastodon: ${DEPLOY_MASTODON}\n"
printf " Deploy BlueSky: ${DEPLOY_BLUESKY}\n"
printf " Deploy Twitter: ${DEPLOY_TWITTER}\n"
printf " Deploy Discord: ${DEPLOY_DISCORD}\n"
printf " Deploy Slack: ${DEPLOY_SLACK}\n"
printf " Original: ${JOBFILE}\n"
printf " Updated: ${INPUT_FILENAME}\n"
printf " Hashtag: ${INPUT_HASHTAG}\n"
printf " Unique: ${INPUT_UNIQUE}\n"
printf " Keys: ${INPUT_KEYS}\n"
printf " Test: ${INPUT_TEST}\n"
COMMAND="python ${ACTION_DIR}/find-updates.py update --keys ${INPUT_KEYS} --unique ${INPUT_UNIQUE} --original ${JOBFILE} --updated ${INPUT_FILENAME} --hashtag ${INPUT_HASHTAG}"
if [[ "${DEPLOY}" == "true" ]]; then
COMMAND="${COMMAND} --deploy"
fi
if [[ "${INPUT_TEST}" == "true" ]]; then
COMMAND="${COMMAND} --test"
fi
if [[ "${DEPLOY_TWITTER}" == "true" ]]; then
COMMAND="${COMMAND} --deploy-twitter"
fi
if [[ "${DEPLOY_MASTODON}" == "true" ]]; then
COMMAND="${COMMAND} --deploy-mastodon"
fi
if [[ "${DEPLOY_SLACK}" == "true" ]]; then
COMMAND="${COMMAND} --deploy-slack"
fi
if [[ "${DEPLOY_DISCORD}" == "true" ]]; then
COMMAND="${COMMAND} --deploy-discord"
fi
if [[ "${DEPLOY_BLUESKY}" == "true" ]]; then
COMMAND="${COMMAND} --deploy-bluesky"
fi
echo "${COMMAND}"
${COMMAND}
echo $?