Skip to content

Commit

Permalink
Get the branch name and the commit sha correctly from github
Browse files Browse the repository at this point in the history
  • Loading branch information
simonweil committed Oct 8, 2024
1 parent e907c5b commit a548e00
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ create_event() {
\"reporter\": \"github_actions\",
\"data\" :{
\"image\" : \"${IMAGE}\",
\"commit_sha\" : \"${GITHUB_SHA}\",
\"commit_sha\" : \"$1\",
\"repository\": \"https://github.com/${GITHUB_REPOSITORY}.git\",
\"branch\": \"${GITHUB_REF_NAME}\",
\"branch\": \"$2\",
\"image_sha\": \"${IMAGE_SHA}\",
\"build_time\" : \"$(date +'%Y-%m-%dT%H:%M:%SZ')\"
}
Expand All @@ -61,9 +61,22 @@ create_event() {
}

main() {
local sha, branch

if [[ ${{ github.event_name }} == "pull_request" ]]; then
branch=$(echo "${{ github.head_ref }}"
sha="${{ github.event.pull_request.head.sha }}"
elif [[ ${{ github.ref_type }} == "branch" ]]; then
branch=$(echo "${{ github.ref_name }}"
sha="${{ github.sha }}"
elif [[ ${{ github.ref_type }} == "tag" ]]; then
branch=$(echo "${{ github.ref_name }}"
sha="${{ github.sha }}"
fi
validate_inputs
get_access_token
create_event
create_event "$sha" "$branch"
}
main

0 comments on commit a548e00

Please sign in to comment.