Test
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
name: github-download-previous-artifacts
|
||||
description: "Download artifacts from a previous Workflow run."
|
||||
inputs:
|
||||
host:
|
||||
description: "Gitea host to query."
|
||||
required: true
|
||||
default: "${{ github.server_url }}"
|
||||
accessToken:
|
||||
description: "Gitea host to query."
|
||||
required: true
|
||||
default: "${{ github.token }}"
|
||||
workflowPattern:
|
||||
description: "Pattern of the workflow name to match."
|
||||
required: true
|
||||
|
||||
@@ -15,34 +15,67 @@
|
||||
// }
|
||||
// }
|
||||
using System.Text.Json;
|
||||
using System.Text;
|
||||
using Gitea.Net.Api;
|
||||
using Gitea.Net.Client;
|
||||
using Gitea.Net.Model;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
Console.WriteLine("Environment Variables:");
|
||||
Console.WriteLine(JsonSerializer.Serialize(Environment.GetEnvironmentVariables()));
|
||||
Console.WriteLine("Arguments:");
|
||||
Console.WriteLine(JsonSerializer.Serialize(args));
|
||||
// Console.WriteLine("Environment Variables:");
|
||||
// Console.WriteLine(JsonSerializer.Serialize(Environment.GetEnvironmentVariables()));
|
||||
// Console.WriteLine("Arguments:");
|
||||
// Console.WriteLine(JsonSerializer.Serialize(args));
|
||||
|
||||
OrganizationApi orgApi = new();
|
||||
|
||||
string jsonInput = args.Length > 0 ? args[0] : "{}";
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(jsonInput);
|
||||
using MemoryStream memoryStream = new(jsonBytes);
|
||||
|
||||
IConfiguration configuration = new ConfigurationBuilder()
|
||||
.AddJsonStream(memoryStream)
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
|
||||
PrintConfiguration(configuration);
|
||||
|
||||
Configuration giteaConfig = GetGiteaConfig(configuration);
|
||||
RepositoryApi repoApi = new(giteaConfig);
|
||||
|
||||
|
||||
string owner = configuration["GITHUB_REPOSITORY_OWNER"]!;
|
||||
string repoName = configuration["GITHUB_REPOSITORY"]!;
|
||||
repoName = Path.GetFileName(repoName);
|
||||
Repository repo = await repoApi.RepoGetAsync(owner, repoName);
|
||||
|
||||
Console.WriteLine($"Repository:\n {JsonSerializer.Serialize(repo)}");
|
||||
|
||||
static void PrintConfiguration(IConfiguration configuration)
|
||||
{
|
||||
foreach (var kvp in configuration.AsEnumerable())
|
||||
{
|
||||
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
static Configuration GetGiteaConfig(IConfiguration configuration)
|
||||
{
|
||||
Configuration config = new();
|
||||
string host = configuration["Gitea:Host"]!;
|
||||
string username = configuration["Gitea:Username"]!;
|
||||
string password = configuration["Gitea:Password"]!;
|
||||
string host = configuration["Host"]!;
|
||||
string username = configuration["Username"]!;
|
||||
string password = configuration["Password"]!;
|
||||
string accessToken = configuration["Token"]!;
|
||||
|
||||
UriBuilder hostUriBuilder = new(host);
|
||||
hostUriBuilder.Path = "/api/v1";
|
||||
string hostUri = hostUriBuilder.ToString();
|
||||
|
||||
config.BasePath = hostUri;
|
||||
config.Username = username;
|
||||
config.Password = password;
|
||||
Configuration config = new()
|
||||
{
|
||||
BasePath = hostUri,
|
||||
AccessToken = accessToken,
|
||||
Username = username,
|
||||
Password = password,
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user