Solve Issue with action #161
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Zodiac Server | |
| on: | |
| push: | |
| branches: | |
| - dev_hari | |
| - dev-fan | |
| - dev_mario | |
| - dev_fang | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@v3 | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build React App | |
| run: yarn build | |
| - name: Determine Branch Name | |
| id: get_branch | |
| run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
| - name: Setup SSH Key | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.NEUROJ_SERVER_SSH_KEY_PRIVATE }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H ${{ secrets.NEUROJ_SERVER }} >> ~/.ssh/known_hosts | |
| - name: Test SSH Connection | |
| run: ssh -v njweb@${{ secrets.NEUROJ_SERVER }} "echo 'SSH Connection Successful'" | |
| - name: Deploy to Server via SCP | |
| run: | | |
| echo "Deploying to /var/www/html/dev/${{ env.BRANCH_NAME }}/" | |
| scp -r ./build/* njweb@${{ secrets.NEUROJ_SERVER }}:/var/www/html/dev/${{ env.BRANCH_NAME }}/ | |
| - name: Restart Server (Only in the deployed folder) | |
| run: | | |
| echo "Restarting services in /var/www/html/dev/${{ env.BRANCH_NAME }}/" | |
| ssh njweb@${{ secrets.NEUROJ_SERVER }} << EOF | |
| cd /var/www/html/dev/${{ env.BRANCH_NAME }}/ && pm2 restart all || echo "No PM2 processes found in this directory" | |
| EOF | |
| - name: Cleanup SSH Key | |
| run: rm -f ~/.ssh/id_rsa |