From c93ad8ecb0463fbf1b97e26d6e724dbd149b3820 Mon Sep 17 00:00:00 2001 From: siimav Date: Sat, 21 Sep 2024 19:52:27 +0300 Subject: [PATCH] Add GH Actions CI --- .../asp.net-core-webapp-on-azure.yml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/asp.net-core-webapp-on-azure.yml diff --git a/.github/workflows/asp.net-core-webapp-on-azure.yml b/.github/workflows/asp.net-core-webapp-on-azure.yml new file mode 100644 index 0000000..91ce97a --- /dev/null +++ b/.github/workflows/asp.net-core-webapp-on-azure.yml @@ -0,0 +1,57 @@ +name: Deploy ASP.NET Core app to Azure Web App + +on: + push: + branches: + - test + pull_request: + branches: + - '*' +# CONFIGURATION +# For help, go to https://github.com/Azure/Actions +# +# 1. Set up the following secrets in your repository: +# AZURE_WEBAPP_PUBLISH_PROFILE +# +# 2. Change these variables for your configuration: +env: + AZURE_WEBAPP_NAME: your-app-name # set this to your application's name + AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root + DOTNET_VERSION: '6.0.x' # set this to the dot net version to use + NODE_VERSION: '20.x' # set this to the node version to use + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + environment: dev + steps: + + # Checkout the repo + - uses: actions/checkout@v4 + + # Setup .NET Core SDK + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + # Run dotnet build and publish + - name: dotnet build and publish + run: | + dotnet restore + dotnet build --configuration Release + dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' + + # Deploy to Azure Web apps + - name: 'Run Azure webapp deploy action using publish profile credentials' + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name + slot-name: 'test' + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation + package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'