Skip to content

Commit

Permalink
added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Bioblaze committed Dec 2, 2024
1 parent bfaf6b4 commit 1193d73
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions .github/actions/cerebro-download-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ runs:
id: fetch_build
shell: bash
run: |
report_error() {
local message="$1"
# Get the line number where the function was called
local lineno="${BASH_LINENO[0]}"
# Get the file name of the script (use $0 if running directly)
local file="${BASH_SOURCE[1]##*/}"
# Trigger GitHub Actions error annotation
echo "::error file=$file,line=$lineno::${message}"
}
# Fetch build data from Cerebro
RESPONSE=$(curl -s -X GET "${{ inputs.cerebro_url }}/api/v1/enginebuilds/${{ inputs.run_id }}/${{ inputs.name }}" \
-H "Content-Type: application/json" \
Expand All @@ -41,10 +53,12 @@ runs:
echo "## Fetching Build Data" >> $GITHUB_STEP_SUMMARY
echo "Run ID: ${{ inputs.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "Build Name: ${{ inputs.name }}" >> $GITHUB_STEP_SUMMARY
echo "Raw Response: $RESPONSE" >> $GITHUB_STEP_SUMMARY
# Check if the request succeeded
if [[ $(echo '$RESPONSE' | jq -r '.success') != "true" ]]; then
echo "Error: Failed to fetch build data. Response:\n $RESPONSE" >> $GITHUB_STEP_SUMMARY
if [[ $(echo "$RESPONSE" | jq -r '.success') != "true" ]]; then
report_error "Error: Failed to fetch build data. Response: $RESPONSE"
exit 1
fi
Expand All @@ -55,6 +69,18 @@ runs:
id: parse_build
shell: bash
run: |
report_error() {
local message="$1"
# Get the line number where the function was called
local lineno="${BASH_LINENO[0]}"
# Get the file name of the script (use $0 if running directly)
local file="${BASH_SOURCE[1]##*/}"
# Trigger GitHub Actions error annotation
echo "::error file=$file,line=$lineno::${message}"
}
# Parse the build_data JSON using fromJSON
build_data=$(echo '${{ steps.fetch_build.outputs.build_data }}' | jq -c '.')
completed_at=$(echo '$build_data' | jq -r '.completed_at')
Expand All @@ -66,13 +92,13 @@ runs:
# Check if completed_at is null
if [[ "$completed_at" == "null" || -z "$completed_at" ]]; then
echo "Error: Build is not completed yet (completed_at is null)." >> $GITHUB_STEP_SUMMARY
report_error "Error: Build is not completed yet (completed_at is null)."
exit 1
fi
# Check if file_url is valid
if [[ "$file_url" == "null" || -z "$file_url" ]]; then
echo "Error: No file URL provided in the build data." >> $GITHUB_STEP_SUMMARY
report_error "Error: No file URL provided in the build data."
exit 1
fi
Expand All @@ -83,6 +109,18 @@ runs:
id: download_file
shell: bash
run: |
report_error() {
local message="$1"
# Get the line number where the function was called
local lineno="${BASH_LINENO[0]}"
# Get the file name of the script (use $0 if running directly)
local file="${BASH_SOURCE[1]##*/}"
# Trigger GitHub Actions error annotation
echo "::error file=$file,line=$lineno::${message}"
}
# Ensure the folder exists
if [ ! -d "${{ inputs.folder }}" ]; then
echo "Folder ${{ inputs.folder }} does not exist. Creating it."
Expand All @@ -97,7 +135,7 @@ runs:
echo "Downloading file from ${{ steps.parse_build.outputs.file_url }} to $FULL_PATH"
curl -L -o "$FULL_PATH" "${{ steps.parse_build.outputs.file_url }}"
if [ $? -ne 0 ]; then
echo "Error: Failed to download the file from ${{ steps.parse_build.outputs.file_url }}" >> $GITHUB_STEP_SUMMARY
report_error "Error: Failed to download the file from ${{ steps.parse_build.outputs.file_url }}" >> $GITHUB_STEP_SUMMARY
exit 1
fi
Expand Down

0 comments on commit 1193d73

Please sign in to comment.