diff --git a/gh-act b/gh-act index 62b960e..d5374fa 100755 --- a/gh-act +++ b/gh-act @@ -243,10 +243,12 @@ function user_json_ { } function user_json { - if [ -f "${TEMPFILE_DIR}/users/$1.json" ]; then - cat "${TEMPFILE_DIR}/users/$1.json" + USER_JSON_FILENAME=${1////_} + USER_JSON_PATH="${TEMPFILE_DIR}/users/${USER_JSON_FILENAME}.json" + if [ -f "${USER_JSON_PATH}" ]; then + cat "${USER_JSON_PATH}" else - user_json_ "$1" | tee "${TEMPFILE_DIR}/users/$1.json" + user_json_ "$1" | tee "${USER_JSON_PATH}" fi } @@ -581,6 +583,11 @@ function issue_event_envs() { fi ISSUE_COMMENT_USER_JSON=$(user_json "${ISSUE_COMMENT_AUTHOR}") fi + + if [[ "${ISSUE_URL}" =~ .*pull.* ]]; then + ISSSUE_PULL_REQUEST_JSON=$(parts_json issue_pull_request) + fi + HEAD_OWNER="${OWNER}" HEAD_REPO="${REPO}" HEAD_USER="${ISSUE_AUTHOR}" diff --git a/templates/issue_comment.json b/templates/issue_comment.json index c10600c..44e0129 100644 --- a/templates/issue_comment.json +++ b/templates/issue_comment.json @@ -4,9 +4,9 @@ "author_association": "${ISSUE_COMMENT_AUTHOR_ASSOCIATION}", "body": "${ISSUE_COMMENT_BODY}", "created_at": "${ISSUE_COMMENT_CREATED_AT}", - "html_url": "https://${GITHUB_HOSTNAME}/${OWNER}/${REPO}/issues/${ISSUE_NUMBER}#issuecomment-${ISSUE_COMMENT_ID}", + "html_url": "https://${GITHUB_HOSTNAME}/${OWNER}/${REPO}/issues/${GHACT_ISSUE_NUMBER}#issuecomment-${ISSUE_COMMENT_ID}", "id": ${ISSUE_COMMENT_ID}, - "issue_url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}/issues/${ISSUE_NUMBER}", + "issue_url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}/issues/${GHACT_ISSUE_NUMBER}", "node_id": "", "performed_via_github_app": null, "reactions": { diff --git a/templates/parts/issue.json b/templates/parts/issue.json index fd5397b..5a98ab4 100644 --- a/templates/parts/issue.json +++ b/templates/parts/issue.json @@ -18,6 +18,7 @@ "node_id": "${ISSUE_NODE_ID}", "number": ${ISSUE_NUMBER}, "performed_via_github_app": null, + "pull_request": ${ISSSUE_PULL_REQUEST_JSON:-null}, "reactions": { "+1": ${ISSUE_REACTION_THUMBS_UP_COUNT:-0}, "-1": ${ISSUE_REACTION_THUMBS_DOWN_COUNT:-0}, diff --git a/templates/parts/issue_pull_request.json b/templates/parts/issue_pull_request.json new file mode 100644 index 0000000..a4c6175 --- /dev/null +++ b/templates/parts/issue_pull_request.json @@ -0,0 +1,7 @@ +{ + "diff_url": "${ISSUE_URL}.diff", + "html_url": "${ISSUE_URL}", + "merged_at": null, + "patch_url": "${ISSUE_URL}.patch", + "url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}/pulls/${GHACT_ISSUE_NUMBER}" +}