Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix faulty error output on empty cache #30

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,36 @@ runs:
- name: Decrypt cached session file
id: decrypt
if: ${{ steps.restore-cache.outcome == 'success' }}
continue-on-error: true
shell: bash
run: |
# Default to no session.
echo "session_found=false" >> $GITHUB_OUTPUT

# Verify that the encrypted session file was restored from cache.
test -s ${{ steps.configure-cache.outputs.path }}
if [ ! -s "${{ steps.configure-cache.outputs.path }}" ]; then
echo "No session file found in cache."
exit 0
fi

# Decrypt the session file.
echo "${{ inputs.pantheon-machine-token }}" | \
openssl enc -d -aes-256-cbc -pbkdf2 -iter 10000 -pass stdin -in ${{ steps.configure-cache.outputs.path }} -out $HOME/.terminus/cache/session

# Check if restored session is still valid
TERMINUS_USER=$(terminus auth:whoami)
# Check for restored user (string) or allow command to fail gracefully.
TERMINUS_USER=$(terminus auth:whoami || true)

# Check TERMINUS_USER for string.
if [ -z "$TERMINUS_USER" ]; then
echo "No valid session found. "
exit 1
exit 0
pwtyler marked this conversation as resolved.
Show resolved Hide resolved
fi

echo "Valid session found: $TERMINUS_USER"
echo "session_found=true" >> $GITHUB_OUTPUT

- name: Authenticate Terminus
id: authenticate
if: ${{ inputs.pantheon-machine-token && steps.decrypt.outcome != 'success' }}
if: ${{ inputs.pantheon-machine-token && steps.decrypt.outputs.session_found != 'true' }}
shell: bash
run: |

Expand Down