Skip to content

Commit ee5b607

Browse files
author
mafyuh
committedJul 31, 2024
Update .forgejo/workflows/CD.yml
1 parent 949eb7e commit ee5b607

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed
 

‎.forgejo/workflows/CD.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
deploy:
88
if: github.event.pull_request.merged == true
9-
runs-on: docker
9+
runs-on: ubuntu-22.04
1010
steps:
1111
- name: Checkout repository
1212
uses: actions/checkout@v4
@@ -22,30 +22,11 @@ jobs:
2222
fi
2323
folders=$(git diff --name-only HEAD~1 HEAD | grep '^docker/' | cut -d/ -f2 | sort | uniq)
2424
echo "Modified folders: $folders"
25-
echo "::set-output name=folders::$folders"
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: docker
41-
needs: deploy
42-
steps:
43-
- name: Checkout repository
44-
uses: actions/checkout@v4
25+
echo "::set-output name=folders::$folders"
4526
4627
- name: Deploy to hosts
4728
run: |
48-
IFS=' ' read -r -a folder_array <<< "${{ needs.deploy.outputs.folders }}"
29+
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
4930
for folder in "${folder_array[@]}"; do
5031
case $folder in
5132
arrs)
@@ -102,8 +83,8 @@ jobs:
10283
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
10384
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
10485
105-
sleep 45
106-
86+
sleep 45 # Delay for 45 seconds before fetching logs
87+
10788
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')
10889
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=json)
10990
echo "AWX Job Logs for folder: $folder"
@@ -113,4 +94,4 @@ jobs:
11394
echo "Absolute End: $(echo "$logs" | jq -r '.range.absolute_end')"
11495
echo "Content:"
11596
echo "$(echo "$logs" | jq -r '.content')"
116-
done
97+
done

0 commit comments

Comments
 (0)
Please sign in to comment.