-
Notifications
You must be signed in to change notification settings - Fork 9
/
entrypoint.sh
executable file
·45 lines (30 loc) · 1.29 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
#!/bin/sh -l
GITHUB_USERNAME="$1"
GITHUB_REPO="$1"
USER_EMAIL="$2"
README_FILE="$3"
echo "Start the job"
CLONE_DIR=$(mktemp -p . -d)
FOLDER=$(mktemp -p . -d)
echo "Start cloning"
# Setup git
git config --global user.email "$USER_EMAIL"
git config --global user.name "$GITHUB_USERNAME"
git config --global user.password "$API_TOKEN_GITHUB"
echo "https://$GITHUB_USERNAME:[email protected]/$GITHUB_USERNAME/$GITHUB_REPO.git"
git clone "https://$GITHUB_USERNAME:[email protected]/$GITHUB_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR"
echo "Finished cloning"
ls -la "$CLONE_DIR"
cd "$CLONE_DIR"
INSERTED_LINE="- $GITHUB_REPOSITORY, [$GITHUB_REF@$GITHUB_SHA](https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)"
DELETE_PREFIX="$GITHUB_REPOSITORY"
# sed "/$DELETE_PREFIX/d" $README_FILE > readme_changed.md
# mv readme_changed.md $README_FILE
grep -v "$DELETE_PREFIX" $README_FILE > readme_changed.md
mv readme_changed.md $README_FILE
sed "/^<!-- START gadpp -->.*/a $INSERTED_LINE" $README_FILE > readme_changed.md
mv readme_changed.md $README_FILE
git remote set-url origin "https://$GITHUB_USERNAME:[email protected]/$GITHUB_USERNAME/$GITHUB_REPO.git"
git add .
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git push origin master