6
6
jobs :
7
7
deploy :
8
8
if : github.event.pull_request.merged == true
9
- runs-on : ubuntu-22.04
9
+ runs-on : docker
10
10
steps :
11
11
- name : Checkout repository
12
12
uses : actions/checkout@v4
@@ -20,13 +20,32 @@ jobs:
20
20
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
21
21
git fetch --unshallow
22
22
fi
23
- folders=$(git diff --name-only HEAD~1 HEAD | cut -d/ -f1 | sort | uniq)
23
+ folders=$(git diff --name-only HEAD~1 HEAD | grep '^docker/' | cut -d/ -f2 | sort | uniq)
24
24
echo "Modified folders: $folders"
25
25
echo "::set-output name=folders::$folders"
26
26
27
+ - name : Set condition for deployment
28
+ id : set-condition
29
+ run : |
30
+ if [ -z "${{ steps.detect-changes.outputs.folders }}" ]; then
31
+ echo "No relevant changes detected."
32
+ echo "::set-output name=continue::false"
33
+ else
34
+ echo "Relevant changes detected."
35
+ echo "::set-output name=continue::true"
36
+ fi
37
+
38
+ conditional-deploy :
39
+ if : needs.deploy.outputs.continue == 'true'
40
+ runs-on : ubuntu-22.04
41
+ needs : deploy
42
+ steps :
43
+ - name : Checkout repository
44
+ uses : actions/checkout@v4
45
+
27
46
- name : Deploy to hosts
28
47
run : |
29
- IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes .outputs.folders }}"
48
+ IFS=' ' read -r -a folder_array <<< "${{ needs.deploy .outputs.folders }}"
30
49
for folder in "${folder_array[@]}"; do
31
50
case $folder in
32
51
arrs)
83
102
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
84
103
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
85
104
86
- sleep 45 # Delay for 45 seconds before fetching logs
87
-
105
+ sleep 45
106
+
88
107
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')
89
108
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=json)
90
109
echo "AWX Job Logs for folder: $folder"
0 commit comments