Skip to content

Commit

Permalink
Fix release permission issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Dec 2, 2022
1 parent 78b1ab3 commit a0f8359
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ jobs:

- name: Create draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}
GITHUB_REPOSITORY: "aaubry/YamlDotNet"
run: ./build.sh CreateGithubRelease
22 changes: 16 additions & 6 deletions tools/build/BuildDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,23 @@ public static void Document(Options options)
");
}

private static string GitHubRepository =>
Program.Host switch
private static string GitHubRepository
{
get
{
Host.AppVeyor => Environment.GetEnvironmentVariable("APPVEYOR_REPO_NAME"),
_ => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")
var repository = Program.Host switch
{
Host.AppVeyor => Environment.GetEnvironmentVariable("APPVEYOR_REPO_NAME"),
_ => Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")
};
if (repository == null)
{
WriteWarning("Could not determine the current repository. Falling-back to sandbox!");
repository = "aaubry/YamlDotNet.Sandbox";
}
return repository;
}
?? "aaubry/YamlDotNet.Sandbox";
}

private static readonly Lazy<HttpClient> GitHubClient = new Lazy<HttpClient>(() =>
{
Expand All @@ -463,7 +473,7 @@ Program.Host switch
gitHubClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
gitHubClient.DefaultRequestHeaders.Add("User-Agent", GitHubRepository.Split('/')[0]);
gitHubClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("token", token);
gitHubClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
return gitHubClient;
});
Expand Down

0 comments on commit a0f8359

Please sign in to comment.