From a6d33da72f78965c664e0d98b1acfb7ac45385c0 Mon Sep 17 00:00:00 2001 From: Samuel Lijin Date: Fri, 12 Jan 2024 10:05:15 -0800 Subject: [PATCH] accumulate errors and check for api token --- action.yaml | 3 ++- src/scripts/prerequisites.sh | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index ebeb421..fb55cfb 100644 --- a/action.yaml +++ b/action.yaml @@ -41,6 +41,8 @@ inputs: runs: using: composite + env: + API_TOKEN: ${{ inputs.trunk-token }} steps: - name: Detect changed paths id: detect-changed-paths @@ -92,7 +94,6 @@ runs: shell: bash env: ACTOR: ${{ github.actor }} - API_TOKEN: ${{ inputs.trunk-token }} REPOSITORY: ${{ github.repository }} TARGET_BRANCH: ${{ steps.prerequisites.outputs.merge_instance_branch }} PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/src/scripts/prerequisites.sh b/src/scripts/prerequisites.sh index a30320c..4234126 100755 --- a/src/scripts/prerequisites.sh +++ b/src/scripts/prerequisites.sh @@ -10,6 +10,13 @@ fetchRemoteGitHistory() { git fetch --quiet --depth=2147483647 origin "$@" } +any_error_occurred=false + +if [[ -z ${API_TOKEN} ]]; then + echo "You must specify a `trunk-token` for trunk-io/merge-action to use" + any_error_occurred=true +fi + # trunk-ignore(shellcheck) pr_branch="${PR_BRANCH}" merge_instance_branch="${TARGET_BRANCH}" @@ -19,7 +26,7 @@ fi if [[ -z ${merge_instance_branch} ]]; then echo "Could not identify merge instance branch" - exit 2 + any_error_occurred=true fi # trunk-ignore(shellcheck/SC2153): Passed in as env variable @@ -62,3 +69,7 @@ echo "pr_branch_head_sha=${pr_branch_head_sha}" >>"${GITHUB_OUTPUT}" echo "impacts_all_detected=${impacts_all_detected}" >>"${GITHUB_OUTPUT}" echo "workspace_path=${workspace_path}" >>"${GITHUB_OUTPUT}" echo "requires_default_bazel_installation=${requires_default_bazel_installation}" >>"${GITHUB_OUTPUT}" + +if [[ "${any_error_occurred}" = true ]]; then + exit 2 +fi \ No newline at end of file