Skip to content

Commit

Permalink
Update docs push script
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert committed Aug 9, 2023
1 parent d7fc6c9 commit ad19882
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions .github/scripts/push-docs-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ set -e
set -x

VERSION=$(cat package.json | jq -r '.version')
CLONE_DIR="./imx-docs"
INPUT_SOURCE_FOLDER="./docs/"
INPUT_DESTINATION_REPO="immutable/imx-docs"
INPUT_DESTINATION_HEAD_BRANCH="ts-immutable-sdk-docs-$VERSION"
INPUT_DESTINATION_FOLDER="api-docs/sdk-references/ts-immutable-sdk/$VERSION"
INPUT_DESTINATION_FOLDER="imx-docs/api-docs/sdk-references/ts-immutable-sdk/$VERSION"

if [ -z "$INPUT_PULL_REQUEST_REVIEWERS" ]
then
Expand All @@ -16,22 +17,21 @@ else
PULL_REQUEST_REVIEWERS='-r '$INPUT_PULL_REQUEST_REVIEWERS
fi

CLONE_DIR=$(mktemp -d)
echo "CLONE_DIR: $CLONE_DIR"

echo "Cloning destination git repository"
# git clone "https://github.com/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR"
git clone "https://oauth2:$GITHUB_TOKEN@github.com/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR"
# echo "CLONE_DIR: $CLONE_DIR"
# echo "Cloning destination git repository"
# # git clone "https://github.com/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR"
# git clone "https://oauth2:[email protected]/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR"

echo "Copying contents to git repo"
mkdir -p $CLONE_DIR/$INPUT_DESTINATION_FOLDER/
mkdir -p $INPUT_DESTINATION_FOLDER

if [ -d "$CLONE_DIR/$INPUT_DESTINATION_FOLDER/" ]; then
if [ -d "$INPUT_DESTINATION_FOLDER" ]; then
### Take action if $DIR exists ###
cp -r $INPUT_SOURCE_FOLDER "$CLONE_DIR/$INPUT_DESTINATION_FOLDER/"
cp -r $INPUT_SOURCE_FOLDER $INPUT_DESTINATION_FOLDER
else
### Control will jump here if $DIR does NOT exists ###
echo "Error: $CLONE_DIR/$INPUT_DESTINATION_FOLDER/ not found. Can not continue."
echo "Error: $INPUT_DESTINATION_FOLDER not found. Can not continue."
exit 1
fi

Expand All @@ -42,8 +42,7 @@ echo "Adding git commit"
git add .
if git status | grep -q "Changes to be committed"
then
# git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git commit --message "Foo"
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
echo "Pushing git commit"
git push -u origin HEAD:$INPUT_DESTINATION_HEAD_BRANCH
echo "Creating a pull request"
Expand Down

0 comments on commit ad19882

Please sign in to comment.