Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output the good error message if plan_workflow_name is wrong #1574

Closed
suzuki-shunsuke opened this issue Mar 11, 2024 · 0 comments · Fixed by #1612
Closed

Output the good error message if plan_workflow_name is wrong #1574

suzuki-shunsuke opened this issue Mar 11, 2024 · 0 comments · Fixed by #1612
Labels
enhancement New feature or request
Milestone

Comments

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Mar 11, 2024

Feature Overview

Output the good error message if plan_workflow_name is wrong.

Why is the feature needed?

Currently, if plan_workflow_name is wrong, it would fail to download plan files.

workflow=$PLAN_WORKFLOW_NAME
pr_head_sha=$(jq -r ".head.sha" "$CI_INFO_TEMP_DIR/pr.json")
# https://github.com/suzuki-shunsuke/tfaction/pull/1570#issuecomment-1987382651
# We don't use gh run list's -c option because
# 1. this requires GitHub CLI v2.40.0 or newer
# 2. we should check the latest workflow run
body=$(gh run list -w "$workflow" -b "$branch" -L 1 --json headSha,databaseId --jq '.[0]')
run_id=$(echo "$body" | jq -r ".databaseId")
head_sha=$(echo "$body" | jq -r ".headSha")
if [ "$head_sha" != "$pr_head_sha" ]; then
echo "::error::workflow run's headSha ($head_sha) is different from the associated pull request's head sha ($pr_head_sha)"
github-comment post \
-config "${GITHUB_ACTION_PATH}/github-comment.yaml" \
-k invalid-workflow-sha \
-var "wf_sha:$head_sha" \
-var "pr_sha:$pr_head_sha"
exit 1
fi

In this case, tfaction should output good an error message so that users can find the root cause.

Example Code

No response

Note

https://twitter.com/b0xp2/status/1767012149732549045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Archived in project
1 participant