Skip to content

Commit

Permalink
Prevents running deploy target on forks
Browse files Browse the repository at this point in the history
This should prevent running the deploy target on forks of this repository. Obviously we can only test that after it's merged...

I also added some comments and refactored a bit to not repeat strings to prevent future errors on them (constansts)...
  • Loading branch information
valadas committed Oct 11, 2021
1 parent 8f8384c commit 986f660
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,23 @@ class Build : NukeBuild
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode

// Default target is defined here for when the build is called without a target.
public static int Main() => Execute<Build>(x => x.Serve);

// Project specific constants
private const string organizationName = "DNNCommunity";
private const string repositoryName = "DNNDocs";
private const string pluginsProjectName = "DNNCommunity.DNNDocs.Plugins";

// CLI parameters.
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

[Parameter("Github Token")]
readonly string GithubToken;

// Nuke features injection.
[Solution] readonly Solution Solution;
[GitRepository] readonly GitRepository repository;

const string pluginsProjectName = "DNNCommunity.DNNDocs.Plugins";
[GitRepository] readonly GitRepository gitRepository;

// Define directories
AbsolutePath siteDirectory = RootDirectory / "docs";
Expand Down Expand Up @@ -177,13 +182,14 @@ private bool IncludeApi()
});

Target Deploy => _ => _
.OnlyWhenDynamic(() => gitRepository.ToString() == $"https://github.com/{organizationName}/{repositoryName}")
.DependsOn(CreateDeployBranch)
.DependsOn(CreateTokenFile)
.DependsOn(Compile)
.Executes(() => {
Git("config --global user.name 'DNN Community'");
Git("config --global user.email 'info@dnncommunity.org'");
Git($"remote set-url origin https://DNNCommunity:{GithubToken}@github.com/DNNCommunity/DNNDocs.git");
Git($"remote set-url origin https://{organizationName}:{GithubToken}@github.com/{organizationName}/{repositoryName}.git");
Git("status");
Git("add docs -f"); // Force adding because it is usually gitignored.
Git("status");
Expand Down

0 comments on commit 986f660

Please sign in to comment.