Skip to content

Commit 43fa799

Browse files
Merge pull request #46 from HubSpot/cc/add-debugging
feat: Add debug mode to project actions
2 parents 4eef770 + 3e33b25 commit 43fa799

File tree

8 files changed

+28
-2
lines changed

8 files changed

+28
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ For example:
7474

7575
## Available Actions
7676

77-
All actions support the `DEFAULT_ACCOUNT_ID` and `DEFAULT_PERSONAL_ACCESS_KEY`, and `DEFAULT_CLI_VERSION` env variables. There's no need to pass them into each action individually as inputs.
77+
All actions support the `DEFAULT_ACCOUNT_ID`, `DEFAULT_PERSONAL_ACCESS_KEY`, `DEFAULT_CLI_VERSION`, and `DEFAULT_DEBUG` env variables. There's no need to pass them into each action individually as inputs.
78+
79+
**TIP:** Set `DEFAULT_DEBUG: true` or pass `debug: true` to any action to enable verbose CLI output. This is useful for troubleshooting failures.
7880

7981
### `Project Upload`
8082

project-deploy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Deploys a specific build of a HubSpot project.
1111
- `account_id` (optional): HubSpot account ID associated with the personal access key. If not provided, will use DEFAULT_ACCOUNT_ID from environment.
1212
- `cli_version` (optional): Version of the HubSpot CLI to install. If not provided, will look for `DEFAULT_CLI_VERSION` in environment. If neither are found, defaults to a pre-determined stable version of the CLI.
1313
- `profile` (optional): Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment.
14+
- `debug` (optional): Enable debug mode for verbose CLI output. Useful for troubleshooting deploy failures. If not provided, will use DEFAULT_DEBUG from environment. Defaults to `false`.
1415

1516
**Outputs:**
1617

project-deploy/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
2929
required: false
3030
type: string
31+
debug:
32+
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands. If not provided, will use DEFAULT_DEBUG from environment."
33+
required: false
34+
type: boolean
3135
outputs:
3236
deploy_id:
3337
description: The deploy ID of the initiated HubSpot project deploy
@@ -46,6 +50,7 @@ runs:
4650
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
4751
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
4852
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
53+
DEBUG_MODE: ${{ inputs.debug || env.DEFAULT_DEBUG}}
4954
run: |
5055
# Source shared utilities
5156
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"

project-upload/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Uploads and builds a HubSpot project in your account. If auto-deploy is enabled,
99
- `account_id` (optional): HubSpot account ID associated with the personal access key. If not provided, will use DEFAULT_ACCOUNT_ID from environment.
1010
- `cli_version` (optional): Version of the HubSpot CLI to install. If not provided, will look for `DEFAULT_CLI_VERSION` in environment. If neither are found, defaults to `latest`.
1111
- `profile` (optional): Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment.
12+
- `debug` (optional): Enable debug mode for verbose CLI output. Useful for troubleshooting upload failures. If not provided, will use DEFAULT_DEBUG from environment. Defaults to `false`.
1213

1314
**Outputs:**
1415

project-upload/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
2323
required: false
2424
type: string
25+
debug:
26+
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands. If not provided, will use DEFAULT_DEBUG from environment."
27+
required: false
28+
type: boolean
2529
outputs:
2630
build_id:
2731
description: "The build ID of the created HubSpot project build"
@@ -40,6 +44,7 @@ runs:
4044
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
4145
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
4246
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
47+
DEBUG_MODE: ${{ inputs.debug || env.DEFAULT_DEBUG}}
4348
run: |
4449
# Source shared utilities
4550
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"

project-validate/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Validates the configuration of a HubSpot project.
99
- `account_id` (optional): HubSpot account ID associated with the personal access key. If not provided, will use DEFAULT_ACCOUNT_ID from environment.
1010
- `cli_version` (optional): Version of the HubSpot CLI to install. If not provided, will look for `DEFAULT_CLI_VERSION` in environment. If neither are found, defaults to a pre-determined stable version of the CLI.
1111
- `profile` (optional): Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment.
12+
- `debug` (optional): Enable debug mode for verbose CLI output. Useful for troubleshooting validation failures. If not provided, will use DEFAULT_DEBUG from environment. Defaults to `false`.
1213

1314
**Outputs:**
1415

project-validate/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
2323
required: false
2424
type: string
25+
debug:
26+
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands. If not provided, will use DEFAULT_DEBUG from environment."
27+
required: false
28+
type: boolean
2529
runs:
2630
using: "composite"
2731
steps:
@@ -35,6 +39,7 @@ runs:
3539
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
3640
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
3741
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
42+
DEBUG_MODE: ${{ inputs.debug || env.DEFAULT_DEBUG}}
3843
run: |
3944
# Source shared utilities
4045
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"

scripts/action-utils.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ resolve_project_dir() {
5959
run_hs_command() {
6060
local command="$1"
6161
local expect_json="${2:-false}"
62+
local debug_flag=""
63+
64+
[ "$DEBUG_MODE" = "true" ] && debug_flag="--debug"
6265

6366
# Run command and capture output
64-
COMMAND_OUTPUT=$(eval "$command")
67+
COMMAND_OUTPUT=$(eval "$command $debug_flag")
6568
local exit_code=$?
6669

70+
# Show output if debug mode is enabled
71+
[ -n "$debug_flag" ] && echo "$COMMAND_OUTPUT"
72+
6773
if [ $exit_code -ne 0 ]; then
6874
echo "Error: Command failed with output:"
6975
echo "$COMMAND_OUTPUT"

0 commit comments

Comments
 (0)