diff --git a/aws/aws-cli/action.yaml b/aws/aws-cli/action.yaml index d55eef6..44d147c 100644 --- a/aws/aws-cli/action.yaml +++ b/aws/aws-cli/action.yaml @@ -13,7 +13,7 @@ inputs: region: description: "AWS region." required: true - default: us-gov-west-1 + default: us-west-1 outputs: console: description: "The console output of the aws command." diff --git a/aws/aws-s3-cp/action.yaml b/aws/aws-s3-cp/action.yaml index 895f7ab..71cead9 100644 --- a/aws/aws-s3-cp/action.yaml +++ b/aws/aws-s3-cp/action.yaml @@ -16,7 +16,7 @@ inputs: region: description: "AWS region." required: true - default: us-gov-west-1 + default: us-west-1 runs: using: "composite" steps: diff --git a/utils/extract/action.yaml b/utils/extract/action.yaml index aade8c4..155b1c1 100644 --- a/utils/extract/action.yaml +++ b/utils/extract/action.yaml @@ -8,6 +8,10 @@ inputs: description: "Directory to extract to." required: false default: "" + fileType: + description: "File type to extract (auto, zip, tgz). Auto will detect based on file extension." + required: false + default: "auto" prefixArgs: description: "Additional arguments to pass in early." required: false @@ -23,24 +27,13 @@ runs: steps: - name: "Build command." id: command - run: | - COMMAND="unzip ${{ inputs.prefixArgs }} -o ${{ inputs.file }} ${{ inputs.additionalArgs }}" - OUTPUT_DIR="${{ inputs.outputDir }}" - if [[ -n "$OUTPUT_DIR" ]]; then - COMMAND="$COMMAND -d \"$OUTPUT_DIR\"" - fi - echo "command=$COMMAND" >> "$GITHUB_OUTPUT" + run: bash ${{ github.action_path }}/extract.sh "${{ inputs.file }}" "${{ inputs.fileType }}" "${{ inputs.outputDir }}" "${{ inputs.prefixArgs }}" "${{ inputs.additionalArgs }}" shell: bash - - name: "Convert file." - id: convert - uses: act/common/distros/busybox@master - with: - args: ${{ steps.command.outputs.command }} - name: "Delete source." run: | if [[ ${{ inputs.deleteSource }} != "true" ]]; then exit 0 fi - + rm ${{ inputs.file }} shell: bash \ No newline at end of file diff --git a/utils/extract/extract.sh b/utils/extract/extract.sh new file mode 100644 index 0000000..d8def58 --- /dev/null +++ b/utils/extract/extract.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail # Best practice: fail fast on errors, unset vars, pipeline failures + +FILE="${1:-}" +FILE_TYPE="${2:-auto}" +OUTPUT_DIR="${3:-}" +PREFIX_ARGS="${4:-}" +ADDITIONAL_ARGS="${5:-}" + +# Validate that a file was provided +if [[ -z "$FILE" ]]; then + echo "Error: No file specified." >&2 + exit 1 +fi + +# Resolve relative paths and check if file exists +if [[ ! -f "$FILE" ]]; then + echo "Error: File not found: '$FILE'" >&2 + exit 1 +fi + +# Auto-detect file type if needed +if [[ "$FILE_TYPE" == "auto" ]]; then + if [[ "$FILE" =~ \.(tar\.gz|tgz)$ ]]; then + FILE_TYPE="tgz" + elif [[ "$FILE" =~ \.zip$ ]]; then + FILE_TYPE="zip" + else + echo "Error: Unable to auto-detect file type from extension '$FILE'. Specify 'zip' or 'tgz'." >&2 + exit 1 + fi +fi + +# Ensure output directory exists if specified +if [[ -n "$OUTPUT_DIR" ]]; then + mkdir -p "$OUTPUT_DIR" +fi + +# Build the extraction command +case "$FILE_TYPE" in + tgz) + COMMAND=(tar $PREFIX_ARGS -xzf "$FILE" $ADDITIONAL_ARGS) + [[ -n "$OUTPUT_DIR" ]] && COMMAND+=(-C "$OUTPUT_DIR") + ;; + zip) + COMMAND=(unzip $PREFIX_ARGS -o "$FILE" $ADDITIONAL_ARGS) + [[ -n "$OUTPUT_DIR" ]] && COMMAND+=(-d "$OUTPUT_DIR") + ;; + *) + echo "Error: Invalid fileType '$FILE_TYPE'. Must be 'auto', 'zip', or 'tgz'." >&2 + exit 1 + ;; +esac + +# Output the built command (for GitHub Actions step output or local debugging) +if [[ -z "${GITHUB_OUTPUT-}" ]]; then + GITHUB_OUTPUT="/dev/stdout" +fi +echo "command=${COMMAND[*]}" >> "$GITHUB_OUTPUT" + +# Execute the command safely using an array (prevents word splitting issues) +exec "${COMMAND[@]}"