From 0b9fd0b5b0f8d75653d65372e5fc33ce5f81c854 Mon Sep 17 00:00:00 2001 From: TitleHHHH Date: Sun, 19 Nov 2023 00:08:33 +0500 Subject: [PATCH] test ci cd --- .github/workflows/continuous.yml | 14 ++++++++++++++ build/Build.cs | 31 ++++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 9e468540..096fb340 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -54,8 +54,22 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.100 + - name: Setup Git + run: | + git config --global url."https://user:${{ secrets.GITHUB_TOKEN }}@github".insteadOf https://github + git config --global user.name HolyClientDeploy + git config --global user.email HolyClientDeploy@github.com + - name: "Git clone" + run: git clone $(git config --get remote.origin.url) -b gh-pages --depth 1 --single-branch ClickOnceArtifacts - name: 'Run: Preview' run: ./build.cmd Preview env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Deploy to branch: deploy" + run: | + cd ClickOnceArtifacts + git add -A + git commit -m "Test CI/CD" + git push diff --git a/build/Build.cs b/build/Build.cs index fac18755..c9e91e14 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -120,7 +120,7 @@ class Build : NukeBuild readonly AbsolutePath HolyClient_Application = ArtifactsDirectory / "bin" / "HolyClient.Desktop.application"; readonly AbsolutePath ApplicationFiles = ArtifactsDirectory / "bin" / "Application Files"; - readonly AbsolutePath ClickOncePreview = RootDirectory / "ClickOnceArtifacts" / "preview"; + readonly AbsolutePath ClickOncePreview = RootDirectory / "ClickOnceArtifacts"; @@ -133,32 +133,33 @@ class Build : NukeBuild x.SetProjectFile(Solution.Platfroms.HolyClient_Desktop) .EnableNoRestore()); - ClickOncePreview.CreateOrCleanDirectory(); + //ClickOncePreview.CreateOrCleanDirectory(); - Repository.Clone( - "https://github.com/Titlehhhh/Minecraft-Holy-Client", - ClickOncePreview, - new CloneOptions() { - BranchName = "deploy" - }); + //string pathRep = Repository.Clone( + // "https://github.com/Titlehhhh/Minecraft-Holy-Client", + // ClickOncePreview, + // new CloneOptions() + // { + + // BranchName = "deploy" + // }); - MSBuildTasks.MSBuild(s => s - + .SetTargetPath(Solution.Platfroms.HolyClient_Desktop) .SetTargets("publish") .SetProperty("PublishProfile", "ClickOnceProfile") .SetProperty("PublishDir", ArtifactsDirectory / "bin")); - + SetupExe.MoveToDirectory(ClickOncePreview); HolyClient_Application.MoveToDirectory(ClickOncePreview); ApplicationFiles.MoveToDirectory(ClickOncePreview); - PushToDeploy(); + //PushToDeploy(); }); @@ -166,7 +167,7 @@ private void PushToDeploy() { try { - + using (var repo = new Repository(ClickOncePreview)) { RepositoryStatus status = repo.RetrieveStatus(); @@ -187,12 +188,12 @@ private void PushToDeploy() { Username = GitHubActions.RepositoryOwner, Password = GitHubActions.Token - } + } }; var pushRefSpec = $"refs/heads/deploy"; repo.Network.Push(remote, pushRefSpec, options); //Push changes to the remote repository - + } } catch (Exception ex)