Skip to content

Commit c48f901

Browse files
committedNov 13, 2024
adjust CD
1 parent f4652d1 commit c48f901

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎.forgejo/workflows/CD.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,20 @@ jobs:
9393
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
9494
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
9595
96-
sleep 45 # Delay for 45 seconds before fetching logs
96+
sleep 45
9797
9898
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')
99-
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=json)
99+
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=txt)
100+
100101
echo "AWX Job Logs for folder: $folder"
101102
echo "Content:"
102-
echo "$(echo "$logs" | jq -r '.content')"
103+
echo "$logs"
104+
105+
# Check for 'failed=' in the play recap
106+
if echo "$logs" | grep -q "failed=[1-9]"; then
107+
echo "Detected failed steps in AWX job. Failing Actions run."
108+
exit 1
109+
else
110+
echo "No failures detected in AWX job."
111+
fi
103112
done

0 commit comments

Comments
 (0)
Please sign in to comment.