This commit is contained in:
2023-04-28 15:15:15 -07:00
parent 0e6e2f40e3
commit 48ce5df1b4
6 changed files with 148 additions and 1 deletions

18
itchio/butler/Dockerfile Normal file
View File

@@ -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"]

25
itchio/butler/action.yaml Normal file
View File

@@ -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 }}

View File

@@ -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<<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