Search code examples
.net-coredeploymentgithub-actionsplesk

How to deploy .NET Core 6 web app to GoDaddy?


I have a simple .NET Core 6 web app, and I have GoDaddy's Windows Hosting Deluxe package. It uses Plesk to manage the sites.

GoDaddy does support .NET Core 6

It appears the only way to get files into Plesk in an automated way is to use FTP. So on github I have this deploy script:

name: 🚀 Deploy website via FTPS
on:
  workflow_dispatch:
  push:
    branches:
      - main
permissions:
  contents: write
jobs:
  web-deploy:
      name: 🎉 Deploy
      runs-on: ubuntu-latest
      steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v3
        
      - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: ${{ matrix.dotnet-version }}
      - name: Install dependencies
        run: dotnet restore
      - name: Build
        run: dotnet build --configuration Release --no-restore

      - name: 📂 Upload files via FTPS
        uses: SamKirkland/[email protected]
        with:
          server: my-real-domain.com
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          local-dir: ./bin/Release/net6.0/
          server-dir: ./
          protocol: ftps
          dangerous-clean-slate: true
          exclude: |
            .cspell.json
            package.json
            package-lock.json

That builds everything just fine, and then uploads the contents of ./bin/Release/net6.0/ to my instance of Plesk on GoDaddy.

But, I just get a big red "403 - Forbidden: Access is denied" error on my site. What am I doing wrong here? Am I uploading the wrong files, or is there something else entirely that I'm missing?


Solution

  • Sorry to answer my own question, but this was a fairly simple fix someone might run into in the future.

    I needed to run dotnet publish instead of dotnet build!

    Then I just need to upload the contents of the ./bin/Release/net6.0/publish/ folder.

    It works now. Here's my working deploy script

    ```yaml
    name: 🚀 Deploy website via FTPS
    on:
      workflow_dispatch:
      push:
        branches:
          - main
    permissions:
      contents: write
    jobs:
      web-deploy:
          name: 🎉 Deploy
          runs-on: ubuntu-latest
          steps:
          - name: 🚚 Get latest code
            uses: actions/checkout@v3
            
          - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
            uses: actions/setup-dotnet@v3
            with:
              dotnet-version: ${{ matrix.dotnet-version }}
          - name: Install dependencies
            run: dotnet restore
          - name: Build
            run: dotnet publish --configuration Release --no-restore
    
          - name: 📂 Upload files via FTPS
            uses: SamKirkland/[email protected]
            with:
              server: my-real-domain.com
              username: ${{ secrets.FTP_USERNAME }}
              password: ${{ secrets.FTP_PASSWORD }}
              local-dir: ./bin/Release/net6.0/publish/
              server-dir: ./
              protocol: ftps
              dangerous-clean-slate: true
              exclude: |
                .cspell.json
                package.json
                package-lock.json