Deploy with GitHub Actions
Build and publish your application on every push with a GitHub Actions workflow.
With GitHub Actions your .NET application is built on GitHub and published to your website through Web Deploy every time you push. The workflow below restores, builds, tests and publishes the project and then uploads the result.
Note
This is different from Git deploy in the Control Panel, where our server pulls and builds the repository. With GitHub Actions the build runs on GitHub and only the finished output is sent to your website.
Enable WebDeploy
Open the Deploy page
Sign in to the Control Panel, go to Websites, select your website and choose Deploy in the left menu.
Enable WebDeploy
On the Visual Studio access card switch WebDeploy to Enabled.
Note the login details
You will need the Server, Site, Login and Password values from this card for the repository secrets.
Create the workflow
Open Actions
Sign in to GitHub, open your repository and select Actions in the top menu.
Start a new workflow
Choose New workflow in the left menu and click set up a workflow yourself.
Paste the workflow
Name the file
publish.ymland paste this content into the editor:name: Build, publish and deploy to MonsterASP.NET on: [push] jobs: build_and_deploy: runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: Setup .NET 8 uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0 - name: Install dependencies run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Publish run: dotnet publish --configuration Release --output ./publish --runtime win-x86 - name: Test with .NET run: dotnet test - name: Deploy to MonsterASP.NET via WebDeploy uses: rasmusbuchholdt/simply-web-deploy@2.1.0 with: website-name: ${{ secrets.WEBSITE_NAME }} server-computer-name: ${{ secrets.SERVER_COMPUTER_NAME }} server-username: ${{ secrets.SERVER_USERNAME }} server-password: ${{ secrets.SERVER_PASSWORD }}Commit
Save (commit) the workflow file.
Add the secrets
The workflow reads the Web Deploy login details from the secrets of the repository, so the password never appears in the workflow file. Add these four repository secrets on GitHub and fill them with the values from the Visual Studio access card:
| Secret | Value |
|---|---|
WEBSITE_NAME |
siteXXXX |
SERVER_COMPUTER_NAME |
https://siteXXXX.siteasp.net:8172 |
SERVER_USERNAME |
siteXXXX |
SERVER_PASSWORD |
Your Web Deploy password |
Run it
From now on every git push to the repository starts the workflow and deploys the application to your website. You can also start the workflow manually on GitHub.
Warning
A deployment script must never leave the application pool of your website stopped. If you extend the workflow with your own step that stops the application before the upload, a failed or cancelled run can end before the start step is reached, and the website then stays offline until you start it again. Use a restart (recycle) instead of a stop without a matching start. If it does happen, start the website with the Start button on its Overview page in the Control Panel.
Something went wrong?
- The deploy step cannot sign in. Check that WebDeploy is still Enabled and that the four secrets match the values on the Deploy page. After changing the Web Deploy password, update
SERVER_PASSWORDtoo. - The application returns an error after the deployment. See HTTP Error 500 – the application failed to start.