Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User/vchintalapat/GitHub actions test #443

Merged
merged 27 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6c9b1a3
Github actions test
Saipriya-1144 Sep 30, 2024
ec18e7f
Github actions test
Saipriya-1144 Sep 30, 2024
abaac2e
Create githubactionstest
Saipriya-1144 Sep 30, 2024
588b05b
modified github actions test
Saipriya-1144 Oct 3, 2024
3f2aea3
copied github_actions_test to other workflow for testsing
Saipriya-1144 Oct 3, 2024
8751410
modified helloController to trigger workflow
Saipriya-1144 Oct 3, 2024
51e9216
added a github action workflow
Saipriya-1144 Oct 3, 2024
5d297e0
removed sln file
Saipriya-1144 Oct 3, 2024
1593b78
modified defaultlabels.yml
Saipriya-1144 Oct 3, 2024
0d666eb
added node sample app
Saipriya-1144 Oct 6, 2024
79292b3
copied this code to defaultLabels.yml for testing
Saipriya-1144 Oct 6, 2024
06cc512
copied this code to defaultLabels.yml for testing
Saipriya-1144 Oct 6, 2024
7fe2efa
modified github_actions_test workflow
Saipriya-1144 Oct 7, 2024
19ad66c
modified node sample app
Saipriya-1144 Oct 7, 2024
13b3c55
modified node app name
Saipriya-1144 Oct 7, 2024
8308b2c
modified node app server.js
Saipriya-1144 Oct 7, 2024
5254800
modified site name for this node app
Saipriya-1144 Oct 7, 2024
f52d595
modified server.js in sample node app
Saipriya-1144 Oct 7, 2024
2467ad1
modified server.js in sample node app
Saipriya-1144 Oct 7, 2024
19d66c3
modified server.js in sample node app
Saipriya-1144 Oct 7, 2024
d337a21
modified github_actions_test.yml
Saipriya-1144 Oct 7, 2024
9adeea5
added new workflow to prebuild and deploy the app
Saipriya-1144 Oct 8, 2024
fa413bb
removed unnecessary workflows
Saipriya-1144 Oct 17, 2024
ceb4c06
modified ci.yml
Saipriya-1144 Oct 17, 2024
fe7f03b
pushed to defaultlabels.yml to trigger workflow
Saipriya-1144 Oct 23, 2024
afc95b5
modified github actions workflow
Saipriya-1144 Oct 23, 2024
cc54675
updated HelloController.cs
Saipriya-1144 Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/defaultLabels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
stale-pr-label: 'idle'
days-before-stale: 14
days-before-close: -1
operations-per-run: 100
operations-per-run: 100
111 changes: 111 additions & 0 deletions .github/workflows/github_actions_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy to Azure App Services

on:
push:
branches:
- master
schedule:
- cron: "0 0/3 * * *"

jobs:
build-and-deploy-dotnet-app:
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Modify the sample app
run: |
cp -r ./__tests__/dotnetsampleapp dotnetapp
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
sed -i "s/<<<net-place-holder>>>/$current_utc_time/g" dotnetapp/Controllers/HelloController.cs

echo "The placeholder has been replaced with current UTC time: $current_utc_time"

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Build with dotnet
run: dotnet build --configuration Release dotnetapp/DOTNET_8_APP.csproj

- name: dotnet publish
run: dotnet publish dotnetapp/DOTNET_8_APP.csproj -c Release -o myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: .net-app
path: myapp

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_DOTNETAPP1 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'lwasv2-euap-dotnet-githubactionstest'
slot-name: 'Production'
package: myapp

build-and-deploy-node-app:
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: modify Node.js App
run: |
cp -r ./__tests__/nodesampleapp nodeapp
current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z")
sed -i "s/<<<node-place-holder>>>/$current_utc_time/g" nodeapp/server.js

echo "The placeholder has been replaced with current UTC time: $current_utc_time"

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: npm install, build, and test
run: |
cd nodeapp
npm install
npm run build --if-present
npm run test --if-present

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: nodeapp

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_NODEAPP1 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'lwasv2-euap-node-githubactions'
slot-name: 'Production'
Saipriya-1144 marked this conversation as resolved.
Show resolved Hide resolved
package: nodeapp
42 changes: 42 additions & 0 deletions __tests__/dotnetsampleapp/Controllers/HelloController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Mvc;

namespace DOTNET_8_APP.Controllers
{
[ApiController]
public class HelloController : Controller
{
private readonly ILogger<HelloController> _logger;
private const string dummyAppSetting = "DUMMY_APPSETTING";

public HelloController(ILogger<HelloController> logger)
{
_logger = logger;
}

[HttpGet]
[Route("/")]
public string Hello()
{
Console.WriteLine("Hello endpoint called!");
return "Hello from .NET 8 App ";
}

[HttpGet]
[Route("/dummy")]
public string DummyAppsetting()
{
Console.WriteLine("Dummy endpoint called!");
var dummyAppSettingValue = Environment.GetEnvironmentVariable(dummyAppSetting);
if (dummyAppSettingValue != null) { return dummyAppSettingValue; }
return "Appsetting not found!";
}

[HttpGet]
[Route("/placeholder")]
public string PlaceHolder()
{
Console.WriteLine("Placeholder endpoint called!");
return "<<<net-place-holder>>>";
}
}
}
15 changes: 15 additions & 0 deletions __tests__/dotnetsampleapp/DOTNET_8_APP.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.7.23375.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions __tests__/dotnetsampleapp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseAuthorization();

app.MapControllers();

app.Run();
8 changes: 8 additions & 0 deletions __tests__/dotnetsampleapp/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions __tests__/dotnetsampleapp/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading
Loading