Skip to content

Commit 49a0110

Browse files
author
Hawkeye Tenderwolf
committed
Improve code comments
1 parent b196959 commit 49a0110

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

action.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ runs:
2828
if: inputs.ddev != 'true'
2929
working-directory: ${{ runner.temp }}
3030
run: |
31+
# Set Terminus cache directory so we don't have to guess.
3132
echo TERMINUS_CACHE_DIR=${TERMINUS_CACHE_DIR:-~/.terminus/cache} >> $GITHUB_ENV
33+
3234
# Also, install Terminus if missing.
3335
hash terminus 2> /dev/null || \
3436
curl -O https://raw.githubusercontent.com/pantheon-systems/terminus-installer/master/builds/installer.phar && \
@@ -38,30 +40,36 @@ runs:
3840
- name: Set some environment variables when using DDEV
3941
if: inputs.ddev == 'true'
4042
run: |
41-
# Set a helper variable to optionally execute commands inside DDEV.
43+
# Set some environment variables when using DDEV
44+
45+
# Helper variable to optionally execute commands inside DDEV.
4246
echo exec='ddev exec' >> $GITHUB_ENV
47+
4348
# Pull DDEV's Terminus cache directory setting into a local variable.
4449
echo -n TERMINUS_CACHE_DIR= >> $GITHUB_ENV
4550
ddev exec 'echo ${TERMINUS_CACHE_DIR:-~/.terminus/cache}' >> $GITHUB_ENV
4651
shell: bash
4752

4853
- name: Ensure Terminus cache directory exists
4954
run: |
55+
# Ensure Terminus cache directory exists.
5056
$exec mkdir -p $TERMINUS_CACHE_DIR
5157
shell: bash
5258

53-
- name: Set a cache path and key
59+
- name: Set a cache path, key, and restore-key
5460
id: cache
5561
run: |
56-
# Set cache path.
62+
# Set cache path, key, and restore-key.
5763
echo "path=${{ runner.temp }}/terminus-session.gpg" >> $GITHUB_OUTPUT
58-
# Set cache restore key.
64+
5965
machine_token_hash=`echo ${{ inputs.pantheon-machine-token }} | sha256sum | head -c 40`
6066
restore_key="terminus-session-$machine_token_hash"
6167
echo "restore-key=$restore_key-" >> $GITHUB_OUTPUT
62-
# Add the GitHub Actions unique "run id" to the cache key so that we can
63-
# force initiating a new session when requested via action input (GitHub
64-
# Actions caches are immutable and can't be updated for a given key).
68+
69+
# Use the GitHub Actions "run id" to uniqify the cache key so that we
70+
# can force initiating a new session when requested via action input
71+
# (GitHub Actions caches are immutable and can't be updated for a given
72+
# key).
6573
# @see https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
6674
echo "key=$restore_key-${{ github.run_id }}" >> $GITHUB_OUTPUT
6775
shell: bash
@@ -81,8 +89,11 @@ runs:
8189
id: decrypt
8290
if: steps.restore-cache.outcome == 'success'
8391
run: |
92+
# Decrypt cached session file and move into Terminus cache directory
93+
8494
# Verify that the encrypted session file was restored from cache.
8595
test -s ${{ steps.cache.outputs.path }}
96+
8697
# Decrypt the session to a temporary file. Using an interim temp output
8798
# file for the encryption/decryption steps avoids errors when the
8899
# destination file already exists, and makes it easier to support DDEV.
@@ -91,20 +102,24 @@ runs:
91102
--pinentry loopback \
92103
--output terminus-session-temp \
93104
${{ steps.cache.outputs.path }}
105+
94106
# Move the session file into place.
95107
$exec mv terminus-session-temp $TERMINUS_CACHE_DIR/session
108+
96109
# Check if restored session is still valid (normally lasts 24 hours).
97110
$exec terminus auth:whoami | grep -v "You are not logged in"
98111
continue-on-error: true
99112
shell: bash
100113

101-
102114
- name: Initiate a new Terminus session if the old one was not valid or
103115
a new session was requested, and encrypt new session file into GitHub
104116
Actions cache path
105117
id: encrypt
106118
if: steps.decrypt.outcome != 'success'
107119
run: |
120+
# Initiate a new Terminus session because the old one was missing or
121+
# expired, and encrypt new session file into GitHub Actions cache path.
122+
108123
$exec terminus auth:login --machine-token ${{ inputs.pantheon-machine-token }}
109124
$exec gpg --symmetric \
110125
--pinentry-mode loopback \

0 commit comments

Comments
 (0)