Update .forgejo/workflows/CD.yml
This commit is contained in:
parent
949eb7e163
commit
ee5b607785
1 changed files with 6 additions and 25 deletions
|
@ -6,7 +6,7 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event.pull_request.merged == true
|
if: github.event.pull_request.merged == true
|
||||||
runs-on: docker
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
@ -22,30 +22,11 @@ jobs:
|
||||||
fi
|
fi
|
||||||
folders=$(git diff --name-only HEAD~1 HEAD | grep '^docker/' | cut -d/ -f2 | sort | uniq)
|
folders=$(git diff --name-only HEAD~1 HEAD | grep '^docker/' | cut -d/ -f2 | sort | uniq)
|
||||||
echo "Modified folders: $folders"
|
echo "Modified folders: $folders"
|
||||||
echo "::set-output name=folders::$folders"
|
echo "::set-output name=folders::$folders"
|
||||||
|
|
||||||
- name: Set condition for deployment
|
|
||||||
id: set-condition
|
|
||||||
run: |
|
|
||||||
if [ -z "${{ steps.detect-changes.outputs.folders }}" ]; then
|
|
||||||
echo "No relevant changes detected."
|
|
||||||
echo "::set-output name=continue::false"
|
|
||||||
else
|
|
||||||
echo "Relevant changes detected."
|
|
||||||
echo "::set-output name=continue::true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
conditional-deploy:
|
|
||||||
if: needs.deploy.outputs.continue == 'true'
|
|
||||||
runs-on: docker
|
|
||||||
needs: deploy
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Deploy to hosts
|
- name: Deploy to hosts
|
||||||
run: |
|
run: |
|
||||||
IFS=' ' read -r -a folder_array <<< "${{ needs.deploy.outputs.folders }}"
|
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
|
||||||
for folder in "${folder_array[@]}"; do
|
for folder in "${folder_array[@]}"; do
|
||||||
case $folder in
|
case $folder in
|
||||||
arrs)
|
arrs)
|
||||||
|
@ -102,8 +83,8 @@ jobs:
|
||||||
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
|
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
|
||||||
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
|
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
|
||||||
|
|
||||||
sleep 45
|
sleep 45 # Delay for 45 seconds before fetching logs
|
||||||
|
|
||||||
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')
|
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=json)
|
||||||
echo "AWX Job Logs for folder: $folder"
|
echo "AWX Job Logs for folder: $folder"
|
||||||
|
@ -113,4 +94,4 @@ jobs:
|
||||||
echo "Absolute End: $(echo "$logs" | jq -r '.range.absolute_end')"
|
echo "Absolute End: $(echo "$logs" | jq -r '.range.absolute_end')"
|
||||||
echo "Content:"
|
echo "Content:"
|
||||||
echo "$(echo "$logs" | jq -r '.content')"
|
echo "$(echo "$logs" | jq -r '.content')"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue