From 2a49db699e82687b19591ebad80121cab539b03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliv=C3=A9r=20Falvai?= Date: Wed, 21 Feb 2024 14:40:03 +0100 Subject: [PATCH] Handle nonexistent deploy path (#196) * Handle nonexistent deploy path * Update main.go Co-authored-by: lpusok <7979773+lpusok@users.noreply.github.com> * Update main.go Co-authored-by: lpusok <7979773+lpusok@users.noreply.github.com> --------- Co-authored-by: lpusok <7979773+lpusok@users.noreply.github.com> --- bitrise.yml | 11 +++++++++++ main.go | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bitrise.yml b/bitrise.yml index 967cf87..0c2a238 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -193,6 +193,17 @@ workflows: - notify_email_list: $NOTIFY_EMAIL_LIST - is_enable_public_page: "true" - debug_mode: "true" + - path::./: + title: Deploy path points to invalid path + inputs: + - build_url: $BITRISE_BUILD_URL + - build_api_token: $BITRISE_BUILD_API_TOKEN + - is_compress: "false" + - deploy_path: /tmp/nonexistent + - notify_user_groups: $NOTIFY_USER_GROUPS + - notify_email_list: $NOTIFY_EMAIL_LIST + - is_enable_public_page: "true" + - debug_mode: "true" - script: title: Output (generated by the Step) tests inputs: diff --git a/main.go b/main.go index 130864f..26d4ee4 100644 --- a/main.go +++ b/main.go @@ -334,9 +334,18 @@ func clearDeployFiles(filesToDeploy []string) []string { } func collectFilesToDeploy(absDeployPth string, config Config, tmpDir string) (filesToDeploy []string, err error) { + pathExists, err := pathutil.IsPathExists(absDeployPth) + if err != nil { + return nil, fmt.Errorf("failed to check if %s exists: %s", absDeployPth, err) + } + if !pathExists { + log.Warnf("Nothing to deploy at %s", absDeployPth) + return + } + isDeployPathDir, err := pathutil.IsDirExists(absDeployPth) if err != nil { - return nil, fmt.Errorf("failed to check if DeployPath (%s) is a directory or a file, error: %s", absDeployPth, err) + return nil, fmt.Errorf("failed to check if %s is a directory or a file: %s", absDeployPth, err) } if !isDeployPathDir {