name: steamcmd
description: install and setup steamcmd
inputs:
  config:
    description: "steam config as base64 encoded gzipped string"
    required: true
runs:
  using: "composite"
  steps:
    - name: Install SteamCMD
      shell: bash
      run: |
        sudo apt-get install lib32gcc-s1 -y
        mkdir -p ~/Steam | true
        cd ~/Steam
        curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
        chmod +x ~/Steam/
        ~/Steam/steamcmd.sh +help +quit

    - name: Steam Auth
      shell: bash
      env:
        STEAM_CONFIG: ${{ inputs.config }}
        STEAM_CONFIG_PATH: ~/.steam/steam/config
      run: |
        mkdir -p $STEAM_CONFIG_PATH
        # Decode the base64 data and save it to the config location
        echo "$STEAM_CONFIG" | base64 -d | gunzip > $STEAM_CONFIG_PATH/config.vdf
        # Set proper permissions
        chmod 755 $STEAM_CONFIG_PATH/config.vdf
