Skip to content

Commit

Permalink
Cleaned up how we get the pr annotate argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ToreMerkely committed Sep 5, 2024
1 parent a0e6f56 commit eb959a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/init_kosli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
USER_DATA_FILENAME=never-alone-user-data.json
PULL_REQUEST_URL_FILE=never-alone-pr-url.txt
./bin/never_alone/get_commit_and_pr_info.sh -c ${GITHUB_SHA} -o ${USER_DATA_FILENAME} -p ${PULL_REQUEST_URL_FILE}
./bin/never_alone/get_commit_and_pr_info.sh -c ${GITHUB_SHA} -o ${USER_DATA_FILENAME}
PR_URL=$(cat ${PULL_REQUEST_URL_FILE})
PR_ANNOTATION_ARG=""
PR_URL=$(cat ${USER_DATA_FILENAME} | jq -r '.pullRequest.url // empty')
PR_ANNOTATE_ARG=""
if [ -n "$PR_URL" ]; then
PR_ANNOTATION_ARG="--annotate pull_request=$PR_URL"
PR_ANNOTATE_ARG="--annotate pull_request=$PR_URL"
fi
kosli attest generic \
Expand All @@ -101,4 +100,4 @@ jobs:
--name=never-alone-data \
--compliant=true \
--user-data="${USER_DATA_FILENAME}" \
${PR_ANNOTATION_ARG}
${PR_ANNOTATE_ARG}
17 changes: 4 additions & 13 deletions bin/never_alone/get_commit_and_pr_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -Eeu
SCRIPT_NAME="get_commit_and_pr_info.sh"
COMMIT=""
NEVER_ALONE_JSON_FILENAME=""
PULL_REQUEST_URL_FILENAME=""


function print_help
Expand All @@ -15,10 +14,9 @@ Use: $SCRIPT_NAME [options]
Script to get commit and pull request info for a commit
Options are:
-h Print this help menu
-c <commit-sha> Commit sha we are gathering data for. Required
-o <output-filename> Name of json file to save result: Required
-p <pr-url-filename> Name of file to put pull reqeust url.
-h Print this help menu
-c <commit-sha> Commit sha we are gathering data for. Required
-o <output-filename> Name of json file to save result: Required
EOF
}

Expand All @@ -38,7 +36,7 @@ function repo_root

function check_arguments
{
while getopts "hc:o:p:" opt; do
while getopts "hc:o:" opt; do
case $opt in
h)
print_help
Expand All @@ -50,9 +48,6 @@ function check_arguments
o)
NEVER_ALONE_JSON_FILENAME=${OPTARG}
;;
p)
PULL_REQUEST_URL_FILENAME=${OPTARG}
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
Expand Down Expand Up @@ -86,10 +81,6 @@ function get_never_alone_data
commit: $commit[0].commit,
pullRequest: $pullRequest[0]
}' > "${result_file}"

if [ -n "${PULL_REQUEST_URL_FILENAME}" ]; then
echo "$pr_data" | jq -r '.[0].url // empty' > ${PULL_REQUEST_URL_FILENAME}
fi
}


Expand Down

0 comments on commit eb959a5

Please sign in to comment.