Skip to content

Instantly share code, notes, and snippets.

@pawelztef
Created November 14, 2020 21:00
Show Gist options
  • Save pawelztef/b15daf5fc681d0ed89cf747366ec1f0a to your computer and use it in GitHub Desktop.
Save pawelztef/b15daf5fc681d0ed89cf747366ec1f0a to your computer and use it in GitHub Desktop.

Revisions

  1. pawelztef created this gist Nov 14, 2020.
    38 changes: 38 additions & 0 deletions post-recieve.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/bash -l

    # After empty repository has been created in deployment location
    # and added as a remote to development repository i.e. local machine
    # add and edit this file to /hooks/post-recieve

    GIT_REPO=$HOME/roisin_beauty_ie_backend_strapi.git
    PUBLIC_WWW=/home/pawel/roisin_beauty_ie
    PUBLIC_WWW_BACKEND=/home/pawel/roisin_beauty_ie/backend

    GREEN='\033[0;32m'
    RED='\033[0;31m'
    NC='\033[0m' # No Color

    kill $(fuser 1337/tcp)
    echo -e "${GREEN}Strapi server stoped.${NC}"

    rm -rf $PUBLIC_WWW_BACKEND
    echo -e "${GREEN}Previous version deleted${NC}"

    git clone $GIT_REPO $PUBLIC_WWW_BACKEND
    echo -e "${GREEN}Repository cloned ${NC}"

    pushd $PUBLIC_WWW_BACKEND
    #ln -s /home/pawel/configs/roisin_beauty_ie/frontend/.env.production ./.env.production
    #echo -e "${GREEN} Configuration file linked ${NC}"

    npm install
    echo -e "${GREEN}Dependencies installed ${NC}"

    npm run build
    echo -e "${GREEN}Strapi admin installed ${NC}"

    NODE_ENV=production nohup npm run start &
    echo -e "${GREEN}Strapi admin server started ${NC}"
    popd

    echo -e "${GREEN}Backend deployed ${NC}"