Skip to content

Commit

Permalink
feat(inputs): totp support (game-ci#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyzi authored Oct 17, 2022
1 parent be98464 commit e37b353
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 26 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ In order to configure this action, configure a step that looks like the followin

_(The parameters are explained below)_

Option A. Using MFA files

```yaml
jobs:
deployToSteam:
Expand All @@ -50,6 +52,31 @@ jobs:
releaseBranch: prerelease
```
Option B. Using TOTP
```yaml
jobs:
deployToSteam:
runs-on: ubuntu-latest
steps:
- uses: CyberAndrii/steam-totp@v1
name: Generate TOTP
id: steam-totp
with:
shared_secret: ${{ secrets.STEAM_SHARED_SECRET }}
- uses: game-ci/steam-deploy@v1
with:
username: ${{ secrets.STEAM_USERNAME }}
password: ${{ secrets.STEAM_PASSWORD }}
totp: ${{ steps.steam-totp.outputs.code }}
appId: 1234560
buildDescription: v1.2.3
rootPath: build
depot1Path: StandaloneWindows64
depot2Path: StandaloneLinux64
releaseBranch: prerelease
```
## Configuration
#### username
Expand All @@ -60,9 +87,13 @@ The username of the Steam Build Account that you created in setup step 1.
The password of the Steam Build Account that you created in setup step 1.
#### totp
Deploying to Steam using TOTP. If this is not passed, `configVdf`, `ssfnFileName`, and `ssfnFileContents` are required.

#### configVdf, ssfnFileName, and ssfnFileContents

Deploying to Steam requires using Multi-Factor Authentication (MFA) through Steam Guard.
Deploying to Steam requires using Multi-Factor Authentication (MFA) through Steam Guard unless `totp` is passed.
This means that simply using username and password isn't enough to authenticate with Steam.
However, it is possible to go through the MFA process only once by setting up GitHub Secrets for configVdf, ssfnFileName, and ssfnFileContents with these steps:
1. Install [Valve's offical steamcmd](https://partner.steamgames.com/doc/sdk/uploading#1) on your local machine. All following steps will also be done on your local machine.
Expand Down
19 changes: 10 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ inputs:
required: true
default: ''
description: 'The password of your builder account.'
totp:
required: false
description: 'The TOTP to use for login. If set, `configVdf`, `ssfnFileName`, and `ssfnFileContents` will be ignored.'
configVdf:
required: true
default: ''
description: 'The contents of STEAM_HOME/config/config.vdf.'
required: false
description: 'The contents of STEAM_HOME/config/config.vdf. Required if `totp` is not set.'
ssfnFileName:
required: true
default: ''
description: 'The basename of the STEAM_HOME/ssfn file.'
required: false
description: 'The basename of the STEAM_HOME/ssfn file. Required if `totp` is not set.'
ssfnFileContents:
required: true
default: ''
description: 'The contents of the file at STEAM_HOME/ssfnFileName.'
required: false
description: 'The contents of the file at STEAM_HOME/ssfnFileName. Required if `totp` is not set.'
appId:
required: true
default: ''
Expand Down Expand Up @@ -80,6 +80,7 @@ runs:
STEAM_CMD: ${{ steps.setup-steamcmd.outputs.executable }}
steam_username: ${{ inputs.username }}
steam_password: ${{ inputs.password }}
steam_totp: ${{ inputs.totp }}
configVdf: ${{ inputs.configVdf }}
ssfnFileName: ${{ inputs.ssfnFileName }}
ssfnFileContents: ${{ inputs.ssfnFileContents }}
Expand Down
45 changes: 29 additions & 16 deletions steam_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,34 +86,47 @@ EOF
cat manifest.vdf
echo ""

echo ""
echo "#################################"
echo "# Copying SteamGuard Files #"
echo "#################################"
echo ""
if [ -n "$steam_totp" ]; then
echo ""
echo "#################################"
echo "# Using SteamGuard TOTP #"
echo "#################################"
echo ""
else
if [ ! -n "$configVdf" ] || [ ! -n "$ssfnFileName" ] || [ ! -n "$ssfnFileContents" ]; then
echo "MFA inputs are missing or incomplete! Cannot proceed."
exit 1
fi

echo "Steam is installed in: $steamdir"
echo ""
echo "#################################"
echo "# Copying SteamGuard Files #"
echo "#################################"
echo ""

mkdir -p "$steamdir/config"
echo "Steam is installed in: $steamdir"

echo "Copying $steamdir/config/config.vdf..."
echo "$configVdf" | base64 -d > "$steamdir/config/config.vdf"
chmod 777 "$steamdir/config/config.vdf"
mkdir -p "$steamdir/config"

echo "Copying $steamdir/ssfn..."
echo "$ssfnFileContents" | base64 -d > "$steamdir/$ssfnFileName"
chmod 777 "$steamdir/$ssfnFileName"
echo "Copying $steamdir/config/config.vdf..."
echo "$configVdf" | base64 -d > "$steamdir/config/config.vdf"
chmod 777 "$steamdir/config/config.vdf"

echo "Finished Copying SteamGuard Files!"
echo ""
echo "Copying $steamdir/ssfn..."
echo "$ssfnFileContents" | base64 -d > "$steamdir/$ssfnFileName"
chmod 777 "$steamdir/$ssfnFileName"

echo "Finished Copying SteamGuard Files!"
echo ""
fi

echo ""
echo "#################################"
echo "# Uploading build #"
echo "#################################"
echo ""

$STEAM_CMD +login "$steam_username" "$steam_password" +run_app_build $manifest_path +quit || (
$STEAM_CMD +login "$steam_username" "$steam_password" "$steam_totp" +run_app_build $manifest_path +quit || (
echo ""
echo "#################################"
echo "# Errors #"
Expand Down

0 comments on commit e37b353

Please sign in to comment.