diff --git a/dotnet/dotnet-10/Dockerfile b/dotnet/dotnet-10/Dockerfile new file mode 100644 index 0000000..81d1fe2 --- /dev/null +++ b/dotnet/dotnet-10/Dockerfile @@ -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"] \ No newline at end of file diff --git a/dotnet/dotnet-10/action.yaml b/dotnet/dotnet-10/action.yaml new file mode 100644 index 0000000..8c451e6 --- /dev/null +++ b/dotnet/dotnet-10/action.yaml @@ -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 }} \ No newline at end of file diff --git a/dotnet/dotnet-10/entrypoint.sh b/dotnet/dotnet-10/entrypoint.sh new file mode 100644 index 0000000..88743f2 --- /dev/null +++ b/dotnet/dotnet-10/entrypoint.sh @@ -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<> "$GITHUB_OUTPUT" + echo "$OUTPUT" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" +fi + +echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT" + +if [[ "$CATCH_ERRORS" != "true" ]]; then + exit $RESULT +fi \ No newline at end of file diff --git a/github/download-previous-artifacts/action.yaml b/github/download-previous-artifacts/action.yaml index 3a396d4..ff80c15 100644 --- a/github/download-previous-artifacts/action.yaml +++ b/github/download-previous-artifacts/action.yaml @@ -27,14 +27,11 @@ runs: ls -al "${{ github.action_path }}" shell: bash - name: "Download artifacts." - uses: https://github.com/actions/github-script@v6 + uses: act/common/dotnet/dotnet-10@master env: WORKFLOW_FILENAME: ${{ inputs.workflowPattern }} ARTIFACT_NAME: ${{ inputs.filePattern }} ARTIFACT_FILENAME: ${{ inputs.artifactName }} UNZIP_DIR: ${{ inputs.unzipDir }} with: - script: | - const script = require('${{ github.action_path }}/download-previous-artifacts.js') - await script({github, context, core}) - shell: node + command: run "${{ github.action_path }}/download-previous-artifacts.cs "${{ toJSON(inputs) }}" diff --git a/github/download-previous-artifacts/download-previous-artifacts.cs b/github/download-previous-artifacts/download-previous-artifacts.cs new file mode 100644 index 0000000..1ad0205 --- /dev/null +++ b/github/download-previous-artifacts/download-previous-artifacts.cs @@ -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; +} \ No newline at end of file