Test
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
name: github-download-previous-artifacts
|
name: github-download-previous-artifacts
|
||||||
description: "Download artifacts from a previous Workflow run."
|
description: "Download artifacts from a previous Workflow run."
|
||||||
inputs:
|
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:
|
workflowPattern:
|
||||||
description: "Pattern of the workflow name to match."
|
description: "Pattern of the workflow name to match."
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -15,34 +15,67 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text;
|
||||||
using Gitea.Net.Api;
|
using Gitea.Net.Api;
|
||||||
using Gitea.Net.Client;
|
using Gitea.Net.Client;
|
||||||
using Gitea.Net.Model;
|
using Gitea.Net.Model;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine("Hello, World!");
|
||||||
Console.WriteLine("Environment Variables:");
|
// Console.WriteLine("Environment Variables:");
|
||||||
Console.WriteLine(JsonSerializer.Serialize(Environment.GetEnvironmentVariables()));
|
// Console.WriteLine(JsonSerializer.Serialize(Environment.GetEnvironmentVariables()));
|
||||||
Console.WriteLine("Arguments:");
|
// Console.WriteLine("Arguments:");
|
||||||
Console.WriteLine(JsonSerializer.Serialize(args));
|
// 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)
|
static Configuration GetGiteaConfig(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
Configuration config = new();
|
string host = configuration["Host"]!;
|
||||||
string host = configuration["Gitea:Host"]!;
|
string username = configuration["Username"]!;
|
||||||
string username = configuration["Gitea:Username"]!;
|
string password = configuration["Password"]!;
|
||||||
string password = configuration["Gitea:Password"]!;
|
string accessToken = configuration["Token"]!;
|
||||||
|
|
||||||
UriBuilder hostUriBuilder = new(host);
|
UriBuilder hostUriBuilder = new(host);
|
||||||
hostUriBuilder.Path = "/api/v1";
|
hostUriBuilder.Path = "/api/v1";
|
||||||
string hostUri = hostUriBuilder.ToString();
|
string hostUri = hostUriBuilder.ToString();
|
||||||
|
|
||||||
config.BasePath = hostUri;
|
Configuration config = new()
|
||||||
config.Username = username;
|
{
|
||||||
config.Password = password;
|
BasePath = hostUri,
|
||||||
|
AccessToken = accessToken,
|
||||||
|
Username = username,
|
||||||
|
Password = password,
|
||||||
|
};
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user