From c48f90194eb5e476b000d6d9d9e99ac85c681f3f Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Wed, 13 Nov 2024 00:22:39 -0500 Subject: [PATCH] adjust CD --- .forgejo/workflows/CD.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/CD.yml b/.forgejo/workflows/CD.yml index 7ff22a9..d636802 100644 --- a/.forgejo/workflows/CD.yml +++ b/.forgejo/workflows/CD.yml @@ -93,11 +93,20 @@ jobs: -d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \ "https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/" - sleep 45 # Delay for 45 seconds before fetching logs + sleep 45 job_id=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/job_templates/13/jobs/?order_by=-id | jq -r '.results[0].id') - logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=json) + logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=txt) + echo "AWX Job Logs for folder: $folder" echo "Content:" - echo "$(echo "$logs" | jq -r '.content')" + echo "$logs" + + # Check for 'failed=' in the play recap + if echo "$logs" | grep -q "failed=[1-9]"; then + echo "Detected failed steps in AWX job. Failing Actions run." + exit 1 + else + echo "No failures detected in AWX job." + fi done