Added many, many more actions.

This commit is contained in:
2025-06-24 15:24:16 -07:00
parent 62fbe4dead
commit 57ef232d2b
108 changed files with 4212 additions and 7 deletions

55
utils/mktemp/action.yaml Normal file
View File

@@ -0,0 +1,55 @@
name: mktemp
description: "Make a temporary file or directory with the specified contents."
inputs:
input:
description: "Contents of the temporary file or directory."
required: false
default: ""
inputType:
description: "How the input should be parsed. Options: raw, file, dir, expression, auto"
required: false
default: auto
outputType:
description: "How the input should be output. Options: file, dir, auto"
required: false
default: auto
transferType:
description: "How the input should be transferred. Options: copy, move"
required: false
default: copy
tmpDir:
description: "Temporary directory. Default: /tmp"
required: true
default: /tmp
additionalArgs:
description: "Additional arguments to pass in."
required: false
outputs:
tmp:
description: "The name of the temporary file or directory."
value: ${{ steps.mktemp.outputs.tmp }}
runs:
using: "composite"
steps:
- name: "Get the proper input type."
if: ${{ inputs.inputType == 'auto' }}
id: getinputtype
uses: act/common/utils/inputtype@master
with:
input: ${{ inputs.input }}
- name: "Make the temporary file."
id: mktemp
run: |
INPUT_TYPE="${{ inputs.inputType }}"
if [[ $INPUT_TYPE == 'auto' ]]; then
INPUT_TYPE="${{ steps.getinputtype.outputs.type }}"
fi
#Store in a heredoc to account for quotes.
INPUT=$(cat <<EOF
${{ inputs.input }}
EOF
)
bash ${{ github.action_path }}/make_temp.sh "$INPUT" "$INPUT_TYPE" "${{ inputs.outputType }}" "${{ inputs.transferType }}" "${{ inputs.tmpDir }}" "${{ inputs.additionalArgs }}"
shell: bash

54
utils/mktemp/make_temp.sh Normal file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
INPUT="$1"
INPUT_TYPE="$2"
OUTPUT_TYPE="$3"
TRANSFER_TYPE="$4"
TMP_DIR="$5"
MKTEMP_ARGS="$6"
# match up the output type to the input type.
if [[ $OUTPUT_TYPE == 'auto' ]]; then
if [[ $INPUT_TYPE == 'raw' ]]; then
OUTPUT_TYPE="file"
elif [[ $INPUT_TYPE == 'expression' ]]; then
OUTPUT_TYPE="dir"
else
OUTPUT_TYPE="$INPUT_TYPE"
fi
fi
if [[ $INPUT_TYPE == 'raw' && $OUTPUT_TYPE == 'dir' && -n "$INPUT" ]]; then
echo "Can't output raw input to a temporary directory."
exit 1
fi
if [[ $OUTPUT_TYPE == "dir" ]]; then
MKTEMP_ARGS="-d $MKTEMP_ARGS"
fi
mkdir -p "$TMP_DIR"
TMP=$(mktemp -p "$TMP_DIR" $MKTEMP_ARGS)
echo "tmp=$TMP" >> "$GITHUB_OUTPUT"
if [[ -z "$INPUT" ]]; then
exit 0
fi
TRANSFER_COMMAND="cp -r"
if [[ $TRANSFER_TYPE == 'move' ]]; then
TRANSFER_COMMAND="mv"
fi
if [[ $INPUT_TYPE == 'raw' ]]; then
echo "$INPUT" > "$TMP"
elif [[ $OUTPUT_TYPE == 'file' ]]; then
$TRANSFER_COMMAND "$INPUT" "$TMP"
elif [[ $OUTPUT_TYPE == 'dir' ]]; then
if [[ $INPUT_TYPE == "expression" ]]; then
$TRANSFER_COMMAND $INPUT "$TMP"
else
$TRANSFER_COMMAND "$INPUT" "$TMP"
fi
fi