forked from rickstaa/action-create-tag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·40 lines (34 loc) · 1.13 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
#!/bin/sh
set -eu
git config --global --add safe.directory "$GITHUB_WORKSPACE" || exit 1
cd "${GITHUB_WORKSPACE}" || exit
if [ -z "${INPUT_TAG}" ]; then
echo "[action-create-tag] No-tag was supplied! Please supply a tag."
exit 1
fi
# Set up variables.
TAG="${INPUT_TAG}"
MESSAGE="${INPUT_MESSAGE:-Release ${TAG}}"
FORCE_TAG="${INPUT_FORCE_PUSH_TAG:-false}"
SHA=${INPUT_COMMIT_SHA:-${GITHUB_SHA}}
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
# Create tag
echo "[action-create-tag] Create tag '${TAG}'."
if [ "${INPUT_FORCE_PUSH_TAG}" = 'true' ]; then
git tag -fa "${TAG}" "${SHA}" -m "${MESSAGE}"
else
git tag -a "${TAG}" "${SHA}" -m "${MESSAGE}"
fi
# Set up remote url for checkout@v1 action.
if [ -n "${INPUT_GITHUB_TOKEN}" ]; then
git remote set-url origin "https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
fi
# Push tag
if [ "${INPUT_FORCE_PUSH_TAG}" = 'true' ]; then
echo "[action-create-tag] Force push tag '${TAG}'."
git push --force origin "${TAG}"
else
echo "[action-create-tag] Push tag '${TAG}'."
git push origin "${TAG}"
fi