-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·47 lines (38 loc) · 1.28 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
#!/bin/sh
set -e
set -x
if [ -z "$INPUT_DESTINATION_BRANCH" ]
then
INPUT_DESTINATION_BRANCH=main
fi
OUTPUT_BRANCH="$INPUT_DESTINATION_BRANCH"
CLONE_DIR=$(mktemp -d)
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory "$CLONE_DIR"
echo "Cloning destination git repository"
git config --global user.email "$INPUT_USER_EMAIL"
git config --global user.name "$INPUT_USER_NAME"
git clone --single-branch --branch $INPUT_DESTINATION_BRANCH "https://x-access-token:$API_TOKEN_GITHUB@github.com/ParadoxGameConverters/ParadoxGameConverters.github.io.git" "$CLONE_DIR"
if [ ! -z "$INPUT_DESTINATION_BRANCH_CREATE" ]
then
git checkout -b "$INPUT_DESTINATION_BRANCH_CREATE"
OUTPUT_BRANCH="$INPUT_DESTINATION_BRANCH_CREATE"
fi
echo "Copying contents to git repo"
mkdir -p $CLONE_DIR/commit_ids
git rev-parse HEAD > "$CLONE_DIR/commit_ids/$INPUT_DESTINATION_FILE"
cd "$CLONE_DIR"
if [ -z "$INPUT_COMMIT_MESSAGE" ]
then
INPUT_COMMIT_MESSAGE="Update from https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
fi
echo "Adding git commit"
git add .
if git status | grep -q "Changes to be committed"
then
git commit --message "$INPUT_COMMIT_MESSAGE"
echo "Pushing git commit"
git push -u origin HEAD:$OUTPUT_BRANCH
else
echo "No changes detected"
fi