From 48ce5df1b4bdb3dda495590a65a4558d670fa799 Mon Sep 17 00:00:00 2001 From: Scion Date: Fri, 28 Apr 2023 15:15:15 -0700 Subject: [PATCH] test --- itchio/butler-push/action.yaml | 55 +++++++++++++++++++++++++++++++ itchio/butler-push/get_channel.sh | 29 ++++++++++++++++ itchio/butler/Dockerfile | 18 ++++++++++ itchio/butler/action.yaml | 25 ++++++++++++++ itchio/butler/entrypoint.sh | 20 +++++++++++ minio/mc/action.yaml | 2 +- 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 itchio/butler-push/action.yaml create mode 100644 itchio/butler-push/get_channel.sh create mode 100644 itchio/butler/Dockerfile create mode 100644 itchio/butler/action.yaml create mode 100644 itchio/butler/entrypoint.sh diff --git a/itchio/butler-push/action.yaml b/itchio/butler-push/action.yaml new file mode 100644 index 0000000..5523fa1 --- /dev/null +++ b/itchio/butler-push/action.yaml @@ -0,0 +1,55 @@ +name: butler-push +description: "Upload files to butler." +inputs: + file: + description: "Input file or folder to upload." + required: true + account: + description: "ItchIo account name." + required: true + project: + description: "ItchIo project name." + required: true + channel: + description: "ItchIo channel name." + required: true + apiKey: + description: "Itch.io API key." + required: true + verion: + description: "The version of the file to upload." + required: true + default: "" +runs: + using: "composite" + steps: + - name: "Get channel." + id: channel + run: bash ${{ github.action_path }}/get_channel.sh "${{ inputs.channel }}" + shell: bash + - name: "Build command." + id: command + run: | + # Replace each space with a backslash and a space + FILE="${{ inputs.file }}" + FILE="${FILE// /\\ }" + + DEST="${{ inputs.account }}/${{ inputs.project }}" + CHANNEL="${{ steps.channel.outputs.channel }}" + if [[ -n "$CHANNEL" ]]; then + DEST="$DEST:$CHANNEL" + fi + + COMMAND="push $FILE $DEST" + + VERSION="${{ inputs.version }}" + if [[ -n "$VERSION" ]]; then + COMMAND="$COMMAND --userversion $VERSION" + fi + echo "command=$COMMAND" >> "$GITHUB_OUTPUT" + shell: bash + - name: "Copy files to/from S3." + uses: act/common/itchio/butler@master + with: + command: ${{ steps.command.outputs.command }} + apiKey: ${{ inputs.apiKey }} diff --git a/itchio/butler-push/get_channel.sh b/itchio/butler-push/get_channel.sh new file mode 100644 index 0000000..18aa648 --- /dev/null +++ b/itchio/butler-push/get_channel.sh @@ -0,0 +1,29 @@ +#!/bin/bash +BUTLER_CHANNEL="$1" + +CHANNEL=$(echo "$BUTLER_CHANNEL" | awk '{print tolower($0)}') +case $CHANNEL in + "windows") + CHANNEL=win64 + ;; + "windows32bit") + CHANNEL=win32 + ;; + "mac") + CHANNEL=osx + ;; + "ios") + CHANNEL=ios + ;; + "linux") + CHANNEL=linux + ;; + "android") + CHANNEL=android + ;; + "webgl") + CHANNEL=webgl + ;; +esac + +echo "channel=$CHANNEL" #>> "$GITHUB_OUTPUT" diff --git a/itchio/butler/Dockerfile b/itchio/butler/Dockerfile new file mode 100644 index 0000000..0bd4070 --- /dev/null +++ b/itchio/butler/Dockerfile @@ -0,0 +1,18 @@ +# Container image that runs your code +FROM debian:stable-slim + +RUN apt-get update && \ + apt-get install -y \ + unzip \ + curl + +RUN curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default + +RUN unzip butler.zip && \ + mv butler /usr/local/bin/butler && \ + rm butler.zip + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/itchio/butler/action.yaml b/itchio/butler/action.yaml new file mode 100644 index 0000000..d2fd261 --- /dev/null +++ b/itchio/butler/action.yaml @@ -0,0 +1,25 @@ +name: butler +description: "Run butler client commands." +inputs: + command: + description: "Arguments to pass into butler." + required: true + apiKey: + description: "Itch.io API key." + required: true + catchErrors: + description: "Whether or not errors should be handled." + required: false +outputs: + console: + description: "The console output of the butler command." + exitCode: + description: "How the program exited." +runs: + using: docker + image: Dockerfile + env: + CATCH_ERRORS: ${{ inputs.catchErrors }} + BUTLER_API_KEY: ${{ inputs.apiKey }} + args: + - ${{ inputs.command }} diff --git a/itchio/butler/entrypoint.sh b/itchio/butler/entrypoint.sh new file mode 100644 index 0000000..a41f34d --- /dev/null +++ b/itchio/butler/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash +ARGS="$@" + +exec 5>&1 +OUTPUT=$(bash -c "butler $ARGS" | 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 diff --git a/minio/mc/action.yaml b/minio/mc/action.yaml index 9dbe4a1..0839c77 100644 --- a/minio/mc/action.yaml +++ b/minio/mc/action.yaml @@ -23,7 +23,7 @@ inputs: required: false outputs: console: - description: "The console output of the aws command." + description: "The console output of the mc command." exitCode: description: "How the program exited." runs: