Implement automatic deployment scripts for frontend and backend with … #53
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 to Production | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # Frontend Deployment | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| cache: "npm" | |
| cache-dependency-path: src/frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: src/frontend | |
| run: npm ci | |
| - name: Build frontend | |
| working-directory: src/frontend | |
| run: npm run build | |
| - name: Deploy to FTP (Frontend) | |
| uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
| with: | |
| server: ${{ secrets.FTP_HOST }} | |
| username: ${{ secrets.FTP_USERNAME }} | |
| password: ${{ secrets.FTP_PASSWORD }} | |
| local-dir: ./src/frontend/dist/ | |
| server-dir: /public_html/ | |
| exclude: | | |
| **/.git* | |
| **/.git*/** | |
| **/node_modules/** | |
| **/.DS_Store | |
| # Backend Deployment | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Restore dependencies | |
| working-directory: src/backend | |
| run: dotnet restore | |
| - name: Build backend | |
| working-directory: src/backend | |
| run: dotnet build --no-restore -c Release | |
| - name: Publish backend | |
| working-directory: src/backend | |
| run: dotnet publish -c Release -o publish --no-build | |
| - name: Deploy to FTP (Backend) | |
| uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
| with: | |
| server: ${{ secrets.FTP_HOST_API }} | |
| username: ${{ secrets.FTP_USERNAME_API }} | |
| password: ${{ secrets.FTP_PASSWORD_API }} | |
| local-dir: ./src/backend/publish/ | |
| server-dir: /public_html/ | |
| exclude: | | |
| **/.git* | |
| **/.git*/** | |
| **/obj/** | |
| **/bin/** | |
| **/.DS_Store |