Refactor code structure for improved readability and maintainability #5
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 Metascience | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Clean server via SSH | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| port: ${{ secrets.SSH_PORT }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| rm -rf /usr/local/apps/metascience_platform/* | |
| rm -rf /usr/local/apps/metascience_platform/.??* | |
| - name: Copy new files to server | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| port: ${{ secrets.SSH_PORT }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| source: "./*" | |
| target: /usr/local/apps/metascience_platform/ | |
| - name: Build project and restart both back and front end using pm2 | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| port: ${{ secrets.SSH_PORT }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| /bin/bash /home/githubdeployer/scripts/deploy_backend.sh | |
| /bin/bash /home/githubdeployer/scripts/deploy_frontend.sh |