From a5419a76b882515a5817a07b8af9c4f1274f97cd Mon Sep 17 00:00:00 2001 From: siimav Date: Sat, 21 Sep 2024 22:18:23 +0300 Subject: [PATCH] Add GH Actions CI --- .github/workflows/deploy-azure-prod.yml | 49 ++++++++++++++++++++++++ .github/workflows/deploy-azure-test.yml | 50 +++++++++++++++++++++++++ RP1AnalyticsWebApp.sln | 6 +-- RP1AnalyticsWebApp/Startup.cs | 1 + RP1AnalyticsWebApp/vite.config.ts | 2 +- 5 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy-azure-prod.yml create mode 100644 .github/workflows/deploy-azure-test.yml diff --git a/.github/workflows/deploy-azure-prod.yml b/.github/workflows/deploy-azure-prod.yml new file mode 100644 index 0000000..010ede8 --- /dev/null +++ b/.github/workflows/deploy-azure-prod.yml @@ -0,0 +1,49 @@ +name: Deploy to Azure (prod) + +on: + push: + branches: + - master +# 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: RP1CareerLog # 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: production + steps: + + - uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set up Node.js version + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: dotnet build and publish + run: | + dotnet restore + dotnet build --configuration Release + dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/azure-prod' + + - name: 'Run Azure webapp deploy action using publish profile credentials' + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/azure-prod' diff --git a/.github/workflows/deploy-azure-test.yml b/.github/workflows/deploy-azure-test.yml new file mode 100644 index 0000000..26ba4d5 --- /dev/null +++ b/.github/workflows/deploy-azure-test.yml @@ -0,0 +1,50 @@ +name: Deploy to Azure (test) + +on: + push: + branches: + - test +# 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: RP1CareerLog # 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: + + - uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set up Node.js version + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: dotnet build and publish + run: | + dotnet restore + dotnet build --configuration Release + dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/azure-test' + + - name: 'Run Azure webapp deploy action using publish profile credentials' + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + slot-name: 'test' + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/azure-test' diff --git a/RP1AnalyticsWebApp.sln b/RP1AnalyticsWebApp.sln index b0bca92..96e4872 100644 --- a/RP1AnalyticsWebApp.sln +++ b/RP1AnalyticsWebApp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29728.190 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RP1AnalyticsWebApp", "RP1AnalyticsWebApp\RP1AnalyticsWebApp.csproj", "{05A4ABFE-19A0-4C2F-B8DA-D2FF352C0FA0}" EndProject @@ -18,9 +18,7 @@ Global {05A4ABFE-19A0-4C2F-B8DA-D2FF352C0FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU {05A4ABFE-19A0-4C2F-B8DA-D2FF352C0FA0}.Release|Any CPU.Build.0 = Release|Any CPU {0765EEF9-9D48-4263-871C-65CC65FC9C03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0765EEF9-9D48-4263-871C-65CC65FC9C03}.Debug|Any CPU.Build.0 = Debug|Any CPU {0765EEF9-9D48-4263-871C-65CC65FC9C03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0765EEF9-9D48-4263-871C-65CC65FC9C03}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RP1AnalyticsWebApp/Startup.cs b/RP1AnalyticsWebApp/Startup.cs index 4b0944c..d21e9f4 100644 --- a/RP1AnalyticsWebApp/Startup.cs +++ b/RP1AnalyticsWebApp/Startup.cs @@ -121,6 +121,7 @@ public void ConfigureServices(IServiceCollection services) services.AddViteServices(options => { + options.Manifest = "vite-manifest.json"; options.Server.Https = true; options.Server.AutoRun = true; }); diff --git a/RP1AnalyticsWebApp/vite.config.ts b/RP1AnalyticsWebApp/vite.config.ts index 18a4fcc..6f82dc2 100644 --- a/RP1AnalyticsWebApp/vite.config.ts +++ b/RP1AnalyticsWebApp/vite.config.ts @@ -53,7 +53,7 @@ export default defineConfig(async () => { }, }, build: { - manifest: true, + manifest: 'vite-manifest.json', emptyOutDir: true, outDir: '../wwwroot', assetsDir: '',