git 웹훅 저장및 처리용 기본적인 스크립트 작성

This commit is contained in:
김판돌 2023-11-19 14:48:05 +09:00
parent 573f246e7a
commit a9e06490bd
32 changed files with 399 additions and 19 deletions

30
Server/Git/AbstractGit.cs Normal file
View File

@ -0,0 +1,30 @@
namespace Server.Git
{
public abstract class AbstractGit
{
/// <summary>
/// 가장먼저 시작해야 하는 스크립트
/// </summary>
public void init()
{
Pull();
//ChangeScript();
//Push();
}
/// <summary>
/// 엑셀 불러오기, 저장, 혹은 배포 까지 작업해야하는 함수
/// </summary>
public abstract void ChangeScript();
private void Pull()
{
}
private void Push()
{
}
}
}

10
Server/Git/XlsxToJson.cs Normal file
View File

@ -0,0 +1,10 @@
namespace Server.Git
{
public class XlsxToJson : AbstractGit
{
public override void ChangeScript()
{
Console.WriteLine("뭔가를 작업하세요");
}
}
}

View File

@ -5,5 +5,6 @@ var app = builder.Build();
ProtocolProcessor.init(); ProtocolProcessor.init();
app.MapPost("/", ProtocolProcessor.Process); app.MapPost("/", ProtocolProcessor.Process);
app.MapPost("/git", GItWebhook.Process);
app.Run(); app.Run();

View File

@ -3,15 +3,15 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:4855", "applicationUrl": "https://0.0.0.0:4861",
"sslPort": 44398 "sslPort": 4862
} }
}, },
"profiles": { "profiles": {
"Server": { "Server": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "https://localhost:4860", "applicationUrl": "https://0.0.0.0:4860",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },

View File

@ -7,8 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="LibGit2Sharp" Version="0.28.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.0" /> <PackageReference Include="NLog" Version="5.2.5" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,48 @@
using NLog;
namespace Server.System
{
public class GItWebhook
{
private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger();
public static string Process(HttpContext context)
{
AbstractService abstractService;
string Response;
try
{
string eaDelivery = context.Request.Headers["X-Gitea-Delivery"];
string eaEvent = context.Request.Headers["X-Gitea-Event"];
string eaEventType = context.Request.Headers["X-Gitea-Event-Type"];
string eaSignature = context.Request.Headers["X-Gitea-Signature"];
Console.WriteLine($"X-Gitea-Delivery : {eaDelivery}");
Console.WriteLine($"X-Gitea-Event : {eaEvent}");
Console.WriteLine($"X-Gitea-Event-Type : {eaEventType}");
Console.WriteLine($"X-Gitea-Signature : {eaSignature}");
ErrorResp error = new ErrorResp();
error.status = 200;
error.message = "Success";
Response = error.ToJson();
}
catch (RuntimeException ex)
{
ErrorResp error = new ErrorResp(ex);
Response = error.ToJson();
logger.Error("GetErrorResponse : " + Response);
}
catch (Exception ex)
{
ErrorResp error = new ErrorResp();
Response = error.ToJson();
logger.Error("GetErrorResponse : " + ex.ToString());
}
return Response;
}
}
}

View File

@ -33,6 +33,7 @@ namespace Server.System {
public static string Process(HttpContext context) { public static string Process(HttpContext context) {
AbstractService abstractService; AbstractService abstractService;
string Response = ""; string Response = "";
try { try {
Protocol cmd = (Protocol)int.Parse(context.Request.Headers["cmd"]); Protocol cmd = (Protocol)int.Parse(context.Request.Headers["cmd"]);

View File

@ -1,9 +1,9 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "None", "Default": "Trace",
"Microsoft.AspNetCore": "None" "Microsoft.AspNetCore": "Trace"
} }
}, },
"AllowedHosts": "localhost" "AllowedHosts": "0.0.0.0;localhost"
} }

View File

@ -0,0 +1,18 @@
2023-11-18 21:28:18.7273|INFO|Server.System.ProtocolProcessor|Server Start
2023-11-18 21:47:53.5657|INFO|Server.System.ProtocolProcessor|Server Start
2023-11-18 21:49:59.4784|INFO|Server.System.ProtocolProcessor|GetRequst : {
"test":"test"
}
2023-11-18 21:49:59.5825|INFO|Server.System.ProtocolProcessor|GetResponse : {"status":200}
2023-11-18 23:09:10.0313|INFO|Server.System.ProtocolProcessor|GetRequst : {
"aaa":"aa"
}
2023-11-18 23:09:10.0313|INFO|Server.System.ProtocolProcessor|GetResponse : {"status":200}
2023-11-18 23:30:18.5940|ERROR|Server.System.ProtocolProcessor|GetErrorResponse : System.ArgumentNullException: Value cannot be null. (Parameter 's')
at System.Int32.Parse(String s)
at Server.System.ProtocolProcessor.Process(HttpContext context) in E:\git\CsServer\Server\System\SystemMain.cs:line 40
2023-11-18 23:30:27.6377|ERROR|Server.System.ProtocolProcessor|GetErrorResponse : System.ArgumentNullException: Value cannot be null. (Parameter 's')
at System.Int32.Parse(String s)
at Server.System.ProtocolProcessor.Process(HttpContext context) in E:\git\CsServer\Server\System\SystemMain.cs:line 40
2023-11-18 23:43:39.7529|INFO|Server.System.ProtocolProcessor|Server Start
2023-11-18 23:46:45.0069|INFO|Server.System.ProtocolProcessor|Server Start

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target
name="logfile"
xsi:type="File"
fileName="Log/${date:format=yyyy-MM-dd}.txt"
archiveAboveSize="10485760"
archiveNumbering="Sequence"
archiveEvery="Day"
maxArchiveFiles="1000"
/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
</nlog>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,57 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"Server/1.0.0": {
"dependencies": {
"NLog": "5.2.0",
"Newtonsoft.Json": "13.0.3"
},
"runtime": {
"Server.dll": {}
}
},
"Newtonsoft.Json/13.0.3": {
"runtime": {
"lib/net6.0/Newtonsoft.Json.dll": {
"assemblyVersion": "13.0.0.0",
"fileVersion": "13.0.3.27908"
}
}
},
"NLog/5.2.0": {
"runtime": {
"lib/netstandard2.0/NLog.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.2.0.1813"
}
}
}
}
},
"libraries": {
"Server/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Newtonsoft.Json/13.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
"path": "newtonsoft.json/13.0.3",
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
},
"NLog/5.2.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-uYBgseY0m/9lQUbZYGsQsTBFOWrfs3iaekzzYMH6vFmpoOAvV8/bp1XxG/suZkwB5h8nAiTJAp7VENWRDKtKPA==",
"path": "nlog/5.2.0",
"hashPath": "nlog.5.2.0.nupkg.sha512"
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft.AspNetCore": "Trace"
}
},
"AllowedHosts": "0.0.0.0;localhost"
}

View File

@ -1 +1 @@
902c29e115196f4455fc7ce177d6c6c5cd7ac55d 0ebb13e4726a5860df23c6995ec57867292f8af6

View File

@ -86,3 +86,28 @@ C:/Users/snowpipe/Desktop/bin/Server/Server/obj/Debug/net6.0/ref/Server.dll
/Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/Server.pdb /Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/Server.pdb
/Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/Server.genruntimeconfig.cache /Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/Server.genruntimeconfig.cache
/Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/ref/Server.dll /Users/pandoli365/Downloads/git/CsServer/Server/obj/Debug/net6.0/ref/Server.dll
E:\git\CsServer\Server\bin\Debug\net6.0\NLog.config
E:\git\CsServer\Server\bin\Debug\net6.0\appsettings.Development.json
E:\git\CsServer\Server\bin\Debug\net6.0\appsettings.json
E:\git\CsServer\Server\bin\Debug\net6.0\Server.exe
E:\git\CsServer\Server\bin\Debug\net6.0\Server.deps.json
E:\git\CsServer\Server\bin\Debug\net6.0\Server.runtimeconfig.json
E:\git\CsServer\Server\bin\Debug\net6.0\Server.dll
E:\git\CsServer\Server\bin\Debug\net6.0\Server.pdb
E:\git\CsServer\Server\bin\Debug\net6.0\Newtonsoft.Json.dll
E:\git\CsServer\Server\bin\Debug\net6.0\NLog.dll
E:\git\CsServer\Server\obj\Debug\net6.0\Server.csproj.AssemblyReference.cache
E:\git\CsServer\Server\obj\Debug\net6.0\Server.GeneratedMSBuildEditorConfig.editorconfig
E:\git\CsServer\Server\obj\Debug\net6.0\Server.AssemblyInfoInputs.cache
E:\git\CsServer\Server\obj\Debug\net6.0\Server.AssemblyInfo.cs
E:\git\CsServer\Server\obj\Debug\net6.0\Server.csproj.CoreCompileInputs.cache
E:\git\CsServer\Server\obj\Debug\net6.0\Server.MvcApplicationPartsAssemblyInfo.cache
E:\git\CsServer\Server\obj\Debug\net6.0\staticwebassets.build.json
E:\git\CsServer\Server\obj\Debug\net6.0\staticwebassets.development.json
E:\git\CsServer\Server\obj\Debug\net6.0\scopedcss\bundle\Server.styles.css
E:\git\CsServer\Server\obj\Debug\net6.0\Server.csproj.CopyComplete
E:\git\CsServer\Server\obj\Debug\net6.0\Server.dll
E:\git\CsServer\Server\obj\Debug\net6.0\refint\Server.dll
E:\git\CsServer\Server\obj\Debug\net6.0\Server.pdb
E:\git\CsServer\Server\obj\Debug\net6.0\Server.genruntimeconfig.cache
E:\git\CsServer\Server\obj\Debug\net6.0\ref\Server.dll

Binary file not shown.

View File

@ -1 +1 @@
79f34c44efd1bfabae6498d1ce4c08cf2f8cb3b1 5a972d05249776184d6dd56cb42ed98944f2aa1f

Binary file not shown.

Binary file not shown.

View File

@ -44,9 +44,13 @@
"net6.0": { "net6.0": {
"targetAlias": "net6.0", "targetAlias": "net6.0",
"dependencies": { "dependencies": {
"LibGit2Sharp": {
"target": "Package",
"version": "[0.28.0, )"
},
"NLog": { "NLog": {
"target": "Package", "target": "Package",
"version": "[5.2.0, )" "version": "[5.2.5, )"
}, },
"Newtonsoft.Json": { "Newtonsoft.Json": {
"target": "Package", "target": "Package",

View File

@ -13,4 +13,7 @@
<SourceRoot Include="C:\Users\acst0\.nuget\packages\" /> <SourceRoot Include="C:\Users\acst0\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" /> <SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup> </ItemGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.320\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('$(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.320\build\LibGit2Sharp.NativeBinaries.props')" />
</ImportGroup>
</Project> </Project>

View File

@ -2,6 +2,77 @@
"version": 3, "version": 3,
"targets": { "targets": {
"net6.0": { "net6.0": {
"LibGit2Sharp/0.28.0": {
"type": "package",
"dependencies": {
"LibGit2Sharp.NativeBinaries": "[2.0.320]"
},
"compile": {
"lib/net6.0/LibGit2Sharp.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/net6.0/LibGit2Sharp.dll": {
"related": ".xml"
}
}
},
"LibGit2Sharp.NativeBinaries/2.0.320": {
"type": "package",
"build": {
"build/LibGit2Sharp.NativeBinaries.props": {}
},
"buildMultiTargeting": {
"buildMultiTargeting/LibGit2Sharp.NativeBinaries.props": {}
},
"runtimeTargets": {
"runtimes/linux-arm/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-arm"
},
"runtimes/linux-arm64/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-arm64"
},
"runtimes/linux-musl-arm/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-musl-arm"
},
"runtimes/linux-musl-arm64/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-musl-arm64"
},
"runtimes/linux-musl-x64/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-musl-x64"
},
"runtimes/linux-x64/native/libgit2-e632535.so": {
"assetType": "native",
"rid": "linux-x64"
},
"runtimes/osx-arm64/native/libgit2-e632535.dylib": {
"assetType": "native",
"rid": "osx-arm64"
},
"runtimes/osx-x64/native/libgit2-e632535.dylib": {
"assetType": "native",
"rid": "osx-x64"
},
"runtimes/win-arm64/native/git2-e632535.dll": {
"assetType": "native",
"rid": "win-arm64"
},
"runtimes/win-x64/native/git2-e632535.dll": {
"assetType": "native",
"rid": "win-x64"
},
"runtimes/win-x86/native/git2-e632535.dll": {
"assetType": "native",
"rid": "win-x86"
}
}
},
"Newtonsoft.Json/13.0.3": { "Newtonsoft.Json/13.0.3": {
"type": "package", "type": "package",
"compile": { "compile": {
@ -15,7 +86,7 @@
} }
} }
}, },
"NLog/5.2.0": { "NLog/5.2.5": {
"type": "package", "type": "package",
"compile": { "compile": {
"lib/netstandard2.0/NLog.dll": { "lib/netstandard2.0/NLog.dll": {
@ -31,6 +102,54 @@
} }
}, },
"libraries": { "libraries": {
"LibGit2Sharp/0.28.0": {
"sha512": "+VGXLAQovtTc41EkUXBKSuu40XcyuWUmQrslpd0CPMGkpnLTgQwoRLSSCRxLSPjYSi9SskyRUOLa9tjg/L108A==",
"type": "package",
"path": "libgit2sharp/0.28.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"App_Readme/CHANGES.md",
"App_Readme/LICENSE.md",
"App_Readme/README.md",
"lib/net472/LibGit2Sharp.dll",
"lib/net472/LibGit2Sharp.xml",
"lib/net6.0/LibGit2Sharp.dll",
"lib/net6.0/LibGit2Sharp.xml",
"libgit2sharp.0.28.0.nupkg.sha512",
"libgit2sharp.nuspec",
"square-logo.png"
]
},
"LibGit2Sharp.NativeBinaries/2.0.320": {
"sha512": "7vIqOhB+5LOi9arXi8IdlkWURpQEiMtnwVP//djA7cQvIVfpC4bZSnQIDe4kwwvsU/w1oH0YkBTgMmpkVndNbg==",
"type": "package",
"path": "libgit2sharp.nativebinaries/2.0.320",
"files": [
".nupkg.metadata",
".signature.p7s",
"build/LibGit2Sharp.NativeBinaries.props",
"build/net46/LibGit2Sharp.NativeBinaries.props",
"buildMultiTargeting/LibGit2Sharp.NativeBinaries.props",
"libgit2/LibGit2Sharp.dll.config",
"libgit2/libgit2.license.txt",
"libgit2/libgit2.png",
"libgit2/libgit2_hash.txt",
"libgit2sharp.nativebinaries.2.0.320.nupkg.sha512",
"libgit2sharp.nativebinaries.nuspec",
"runtimes/linux-arm/native/libgit2-e632535.so",
"runtimes/linux-arm64/native/libgit2-e632535.so",
"runtimes/linux-musl-arm/native/libgit2-e632535.so",
"runtimes/linux-musl-arm64/native/libgit2-e632535.so",
"runtimes/linux-musl-x64/native/libgit2-e632535.so",
"runtimes/linux-x64/native/libgit2-e632535.so",
"runtimes/osx-arm64/native/libgit2-e632535.dylib",
"runtimes/osx-x64/native/libgit2-e632535.dylib",
"runtimes/win-arm64/native/git2-e632535.dll",
"runtimes/win-x64/native/git2-e632535.dll",
"runtimes/win-x86/native/git2-e632535.dll"
]
},
"Newtonsoft.Json/13.0.3": { "Newtonsoft.Json/13.0.3": {
"sha512": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==", "sha512": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
"type": "package", "type": "package",
@ -61,10 +180,10 @@
"packageIcon.png" "packageIcon.png"
] ]
}, },
"NLog/5.2.0": { "NLog/5.2.5": {
"sha512": "uYBgseY0m/9lQUbZYGsQsTBFOWrfs3iaekzzYMH6vFmpoOAvV8/bp1XxG/suZkwB5h8nAiTJAp7VENWRDKtKPA==", "sha512": "mMXtbAxfNzqkXcBjhJ3wN3rH7kwUZ0JL0GrUBI/lso7+tQ/HC4e5SnlmR3R5qQ9zWbqMbjxeH37rIf0yQGWTiA==",
"type": "package", "type": "package",
"path": "nlog/5.2.0", "path": "nlog/5.2.5",
"files": [ "files": [
".nupkg.metadata", ".nupkg.metadata",
".signature.p7s", ".signature.p7s",
@ -81,14 +200,15 @@
"lib/netstandard1.5/NLog.xml", "lib/netstandard1.5/NLog.xml",
"lib/netstandard2.0/NLog.dll", "lib/netstandard2.0/NLog.dll",
"lib/netstandard2.0/NLog.xml", "lib/netstandard2.0/NLog.xml",
"nlog.5.2.0.nupkg.sha512", "nlog.5.2.5.nupkg.sha512",
"nlog.nuspec" "nlog.nuspec"
] ]
} }
}, },
"projectFileDependencyGroups": { "projectFileDependencyGroups": {
"net6.0": [ "net6.0": [
"NLog >= 5.2.0", "LibGit2Sharp >= 0.28.0",
"NLog >= 5.2.5",
"Newtonsoft.Json >= 13.0.3" "Newtonsoft.Json >= 13.0.3"
] ]
}, },
@ -136,9 +256,13 @@
"net6.0": { "net6.0": {
"targetAlias": "net6.0", "targetAlias": "net6.0",
"dependencies": { "dependencies": {
"LibGit2Sharp": {
"target": "Package",
"version": "[0.28.0, )"
},
"NLog": { "NLog": {
"target": "Package", "target": "Package",
"version": "[5.2.0, )" "version": "[5.2.5, )"
}, },
"Newtonsoft.Json": { "Newtonsoft.Json": {
"target": "Package", "target": "Package",

View File

@ -1,11 +1,13 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "nAqHvp85kG/dxMFPmtYjzpHV3dnXt8YWmo54TZ7v2WzSMy2vH9bbR3gEdxF97NrXNm7/1LkqUkiVnR1ZowcrjA==", "dgSpecHash": "x1DxGFfxuYrUX7QMwLpSQJQng7Fs820NfXla2dKNtpZrhdrifLxxFuaaV+JE0Cmi0GmNNXOIu1eed4pUxBBatg==",
"success": true, "success": true,
"projectFilePath": "E:\\git\\CsServer\\Server\\Server.csproj", "projectFilePath": "E:\\git\\CsServer\\Server\\Server.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [
"C:\\Users\\acst0\\.nuget\\packages\\libgit2sharp\\0.28.0\\libgit2sharp.0.28.0.nupkg.sha512",
"C:\\Users\\acst0\\.nuget\\packages\\libgit2sharp.nativebinaries\\2.0.320\\libgit2sharp.nativebinaries.2.0.320.nupkg.sha512",
"C:\\Users\\acst0\\.nuget\\packages\\newtonsoft.json\\13.0.3\\newtonsoft.json.13.0.3.nupkg.sha512", "C:\\Users\\acst0\\.nuget\\packages\\newtonsoft.json\\13.0.3\\newtonsoft.json.13.0.3.nupkg.sha512",
"C:\\Users\\acst0\\.nuget\\packages\\nlog\\5.2.0\\nlog.5.2.0.nupkg.sha512" "C:\\Users\\acst0\\.nuget\\packages\\nlog\\5.2.5\\nlog.5.2.5.nupkg.sha512"
], ],
"logs": [] "logs": []
} }