Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

using System.Net.Http.Headers; using System.Text; using System.Text.Json;

var token = Environment.GetEnvironmentVariable("GITHUB_TOKEN");

if (string.IsNullOrWhiteSpace(token)) { throw new InvalidOperationException( "GITHUB_TOKEN environment variable is not set."); }

using var client = new HttpClient();

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));

client.DefaultRequestHeaders.UserAgent.ParseAdd("my-csharp-app");

var payload = new { event_type = "run-playwright-tests", client_payload = new { git = new { sha = "12345" }, slvip_url = "https://slvip.example.com", casinoplus_url = "https://casinoplus.example.com" } };

var json = JsonSerializer.Serialize(payload);

using var content = new StringContent( json, Encoding.UTF8, "application/json");

var response = await client.PostAsync( "https://api.github.com/repos/OWNER/REPOSITORY/dispatches", content);

var responseText = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode) { throw new HttpRequestException( $"GitHub API returned {(int)response.StatusCode} " + $"{response.ReasonPhrase}: {responseText}"); }

Console.WriteLine("Dispatch event sent successfully.");

Releases

Packages

Contributors