Skip to content

Commit

Permalink
accumulate errors and check for api token
Browse files Browse the repository at this point in the history
  • Loading branch information
sxlijin authored Jan 12, 2024
1 parent 63d211a commit a6d33da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ inputs:

runs:
using: composite
env:
API_TOKEN: ${{ inputs.trunk-token }}
steps:
- name: Detect changed paths
id: detect-changed-paths
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion src/scripts/prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Check notice on line 16 in src/scripts/prerequisites.sh

View check run for this annotation

Trunk-Staging.io / Trunk Check

shellcheck(SC2006)

[new] Use $(...) notation instead of legacy backticks `...`.

Check notice on line 16 in src/scripts/prerequisites.sh

View check run for this annotation

Trunk-Staging.io / Trunk Check

shellcheck(SC2312)

[new] Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
any_error_occurred=true
fi

# trunk-ignore(shellcheck)
pr_branch="${PR_BRANCH}"
merge_instance_branch="${TARGET_BRANCH}"
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit a6d33da

Please sign in to comment.