This commit is contained in:
2025-06-30 00:58:23 -07:00
parent c7de24644f
commit 5feab19890
5 changed files with 110 additions and 5 deletions

View File

@@ -0,0 +1,14 @@
ARG VERSION=10.0.100-preview.5
FROM mcr.microsoft.com/dotnet/sdk:$VERSION
RUN apt update
RUN apt install curl -y
# Add tools to Path.
RUN echo 'export PATH="$PATH:$HOME/.dotnet/tools/"' | tee -a "$HOME/.bashrc" > /dev/null
# Install NugetForUnity tool: https://github.com/GlitchEnzo/NuGetForUnity
RUN dotnet tool install --global NuGetForUnity.Cli
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -0,0 +1,21 @@
name: dotnet-10
description: "Run a dotnet command."
inputs:
command:
description: "Dotnet command to run."
required: false
program:
description: "Program to run instead of dotnet. Default: dotnet"
required: false
default: "dotnet"
catchErrors:
description: "Whether or not errors should be handled."
required: false
runs:
env:
PROGRAM: ${{ inputs.program }}
CATCH_ERRORS: ${{ inputs.catchErrors }}
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.command }}

View File

@@ -0,0 +1,25 @@
#!/bin/bash
COMMAND="$@"
set -o pipefail
# Add root tools to Path.
export PATH="$PATH:/root/.dotnet/tools/"
PROGRAM=${PROGRAM:-"dotnet"}
exec 5>&1
OUTPUT=$(bash -c "$PROGRAM $COMMAND" | tee /dev/fd/5)
RESULT=$?
#Output multiline strings.
#https://trstringer.com/github-actions-multiline-strings/
if [[ -n "$OUTPUT" ]]; then
echo "console<<EOF" >> "$GITHUB_OUTPUT"
echo "$OUTPUT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
fi
echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT"
if [[ "$CATCH_ERRORS" != "true" ]]; then
exit $RESULT
fi

View File

@@ -27,14 +27,11 @@ runs:
ls -al "${{ github.action_path }}" ls -al "${{ github.action_path }}"
shell: bash shell: bash
- name: "Download artifacts." - name: "Download artifacts."
uses: https://github.com/actions/github-script@v6 uses: act/common/dotnet/dotnet-10@master
env: env:
WORKFLOW_FILENAME: ${{ inputs.workflowPattern }} WORKFLOW_FILENAME: ${{ inputs.workflowPattern }}
ARTIFACT_NAME: ${{ inputs.filePattern }} ARTIFACT_NAME: ${{ inputs.filePattern }}
ARTIFACT_FILENAME: ${{ inputs.artifactName }} ARTIFACT_FILENAME: ${{ inputs.artifactName }}
UNZIP_DIR: ${{ inputs.unzipDir }} UNZIP_DIR: ${{ inputs.unzipDir }}
with: with:
script: | command: run "${{ github.action_path }}/download-previous-artifacts.cs "${{ toJSON(inputs) }}"
const script = require('${{ github.action_path }}/download-previous-artifacts.js')
await script({github, context, core})
shell: node

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env -S dotnet run
#:package Gitea.Net.API@25.3.*
// static class Program
// {
// static void Main(string[] args)
// {
// Run();
// }
// static void Run()
// {
// // Your code here
// Console.WriteLine("Running the program...");
// }
// }
using System.Text.Json;
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));
OrganizationApi orgApi = new();
static Configuration GetGiteaConfig(IConfiguration configuration)
{
Configuration config = new();
string host = configuration["Gitea:Host"]!;
string username = configuration["Gitea:Username"]!;
string password = configuration["Gitea:Password"]!;
UriBuilder hostUriBuilder = new(host);
hostUriBuilder.Path = "/api/v1";
string hostUri = hostUriBuilder.ToString();
config.BasePath = hostUri;
config.Username = username;
config.Password = password;
return config;
}