From d54d6c631b20b628ec08ee9d85f1c51368b25ffe Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 15:58:25 +0200 Subject: [PATCH 01/12] github workflow has been added --- .github/workflows/pr-verify.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/pr-verify.yml diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml new file mode 100644 index 00000000..0cbaad07 --- /dev/null +++ b/.github/workflows/pr-verify.yml @@ -0,0 +1,33 @@ +name: PR Verify + +# These are the veriables which you could use in your workflows +env: + AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App + AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root + DOTNET_VERSION: '8.0' # set this to the .NET Core version to use + +on: + push: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + name: PR Verify + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Build with dotnet + run: dotnet build --configuration Release + + \ No newline at end of file From 434cdaad649d274d1504a8b6f0cf77f9f975fe14 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 16:02:32 +0200 Subject: [PATCH 02/12] Minor change --- src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs b/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs index 786b4a10..95bc0498 100644 --- a/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs +++ b/src/GitHubActionsDotNet.Api/Models/WeatherForecast.cs @@ -6,7 +6,8 @@ public record WeatherForecast public int TemperatureC { get; init; } - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + public int TemperatureF => 32 + (int)(TemperatureC / 0.555633); public string? Summary { get; init; } } + From 177334828db45278417818083a561d031cfd82bf Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 16:41:57 +0200 Subject: [PATCH 03/12] included the test --- .github/workflows/pr-verify.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index 0cbaad07..e5c3c4f5 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -30,4 +30,9 @@ jobs: - name: Build with dotnet run: dotnet build --configuration Release + + - name: Running test + run: dotnet build --configuration Release --no--build + + \ No newline at end of file From 4b93b2e60a3b044c94d66f504c78836b315c46f7 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 17:17:23 +0200 Subject: [PATCH 04/12] correction in testing command --- .github/workflows/pr-verify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index e5c3c4f5..ee048f1b 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -32,7 +32,7 @@ jobs: - name: Running test - run: dotnet build --configuration Release --no--build - + run: dotnet test --configuration Release --no--build + \ No newline at end of file From 7fe8cf10c6c616e8966adbf50a41ffc211d30b81 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 17:19:50 +0200 Subject: [PATCH 05/12] final testing change --- .github/workflows/pr-verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index ee048f1b..e0dfd6fd 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -32,7 +32,7 @@ jobs: - name: Running test - run: dotnet test --configuration Release --no--build + run: dotnet test --configuration Release --no-build \ No newline at end of file From c9842ba9ded445f347caf6ce6261c4d962c91c4f Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 17:47:11 +0200 Subject: [PATCH 06/12] Generate Artifact --- .github/workflows/pr-verify.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index e0dfd6fd..f8283852 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -30,9 +30,12 @@ jobs: - name: Build with dotnet run: dotnet build --configuration Release - - name: Running test run: dotnet test --configuration Release --no-build + + - name: publish project + run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts + \ No newline at end of file From ff4d74a0a7ae776f1e022d27703834625ad311a3 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 18:18:02 +0200 Subject: [PATCH 07/12] Upload artifacts as part of CI --- .github/workflows/pr-verify.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index f8283852..36162b60 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -36,6 +36,11 @@ jobs: - name: publish project run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts + - uses: actions/upload-artifact@v4 + with: + name: my-artifact + path: artifacts/ + \ No newline at end of file From 998c0628be18a871059db70f534e1f40d4d9853a Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 22:58:29 +0200 Subject: [PATCH 08/12] changed --- .github/workflows/cron.yml | 14 ++++++++++++++ .github/workflows/pr-verify.yml | 3 +-- .github/workflows/secrets.yml | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cron.yml create mode 100644 .github/workflows/secrets.yml diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 00000000..cd1dc536 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,14 @@ +name: Run Every 5 Minutes +# it can be drop from schedule if they experiencing high load. +on: + schedule: + - cron: '*/59 * * * *' + +jobs: + cron: + name: Run every 5 minutes + runs-on: ubuntu-latest + + steps: + - name: Hello World + run: echo "Hello World" \ No newline at end of file diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index 36162b60..ef61168a 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -7,9 +7,8 @@ env: DOTNET_VERSION: '8.0' # set this to the .NET Core version to use on: - push: + pull_request: branches: [ "main" ] - workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 00000000..9566951f --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,24 @@ +name: Secrets workflow + +# These are the veriables which you could use in your workflows +env: + API_CSPROJ_PATH: "./src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj" + +on: + pull_request: + branches: ["main"] + + +jobs: + secrets: + name: Secrets Demo + runs-on: ubuntu-latest + + steps: + - name: echo environment variable + run: echo "$API_CSPROJ_PATH" + + + + + \ No newline at end of file From 83c105bd7ed00140d9f796611ed06acdf1138b9c Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 23:12:15 +0200 Subject: [PATCH 09/12] hiding secret value --- .github/workflows/secrets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml index 9566951f..fa49ab76 100644 --- a/.github/workflows/secrets.yml +++ b/.github/workflows/secrets.yml @@ -16,7 +16,7 @@ jobs: steps: - name: echo environment variable - run: echo "$API_CSPROJ_PATH" + run: echo "$API_CSPROJ_PATH is value ${{ SECRET_API_KEY }}" From 840533c5a21878dbcf3c5d5380233d5dfa230f48 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Fri, 3 Oct 2025 23:35:21 +0200 Subject: [PATCH 10/12] Add Secret --- .github/workflows/secrets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml index fa49ab76..c02462fe 100644 --- a/.github/workflows/secrets.yml +++ b/.github/workflows/secrets.yml @@ -16,7 +16,7 @@ jobs: steps: - name: echo environment variable - run: echo "$API_CSPROJ_PATH is value ${{ SECRET_API_KEY }}" + run: echo "$API_CSPROJ_PATH is value ${{ secrets.SECRET_API_KEY }}" From 39f39d48465cf95c621f5b6783a8f66ec82d5026 Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Sat, 4 Oct 2025 13:34:28 +0200 Subject: [PATCH 11/12] cd has been included --- .github/workflows/cron.yml | 14 -------------- .github/workflows/pr-verify.yml | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 .github/workflows/cron.yml diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml deleted file mode 100644 index cd1dc536..00000000 --- a/.github/workflows/cron.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Run Every 5 Minutes -# it can be drop from schedule if they experiencing high load. -on: - schedule: - - cron: '*/59 * * * *' - -jobs: - cron: - name: Run every 5 minutes - runs-on: ubuntu-latest - - steps: - - name: Hello World - run: echo "Hello World" \ No newline at end of file diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index ef61168a..c708580d 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -2,7 +2,7 @@ name: PR Verify # These are the veriables which you could use in your workflows env: - AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App + AZURE_WEBAPP_NAME: app-dev-rajsonawala.azurewebsites.net # set this to the name of your Azure Web App AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root DOTNET_VERSION: '8.0' # set this to the .NET Core version to use @@ -40,6 +40,24 @@ jobs: name: my-artifact path: artifacts/ + deploy_dev: + name: Deploy Dev + runs-on: ubuntu-latest + needs: build # wait for other job to finish g + + steps: + + - uses: actions/download-artifact@v4 + with: + name: my-artifact + path: artifacts/ + + # Deploy to Azure Web apps + - name: 'Deploy to Azure App Service' + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name + package: 'artifacts/' \ No newline at end of file From 2514a4d6d152ffce52d0554cd5b0a1a68f7b671e Mon Sep 17 00:00:00 2001 From: rajson49-hue Date: Sat, 4 Oct 2025 13:59:41 +0200 Subject: [PATCH 12/12] ci cd azure login has been included --- .github/workflows/pr-verify.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-verify.yml b/.github/workflows/pr-verify.yml index c708580d..484a2c50 100644 --- a/.github/workflows/pr-verify.yml +++ b/.github/workflows/pr-verify.yml @@ -46,12 +46,19 @@ jobs: needs: build # wait for other job to finish g steps: - - uses: actions/download-artifact@v4 with: name: my-artifact path: artifacts/ + - name: Azure login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenate-id: ${{ secrets.AZURE_TENATE_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + # Deploy to Azure Web apps - name: 'Deploy to Azure App Service' uses: azure/webapps-deploy@v2