Compare commits

..

No commits in common. "1c920c087b0a0b8168151e1925677f160d5dd038" and "f2fe90f4c63777993aeaa4edc1cfc014a07248c0" have entirely different histories.

4 changed files with 26 additions and 48 deletions

View file

@ -6,7 +6,7 @@ on:
jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
runs-on: docker
steps:
- name: Checkout repository
uses: actions/checkout@v4
@ -24,9 +24,28 @@ jobs:
echo "Modified 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
run: |
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
IFS=' ' read -r -a folder_array <<< "${{ needs.deploy.outputs.folders }}"
for folder in "${folder_array[@]}"; do
case $folder in
arrs)
@ -83,7 +102,7 @@ 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)

View file

@ -1,10 +1,2 @@
# iac
Currently migrating [Auto-Homelab](https://git.mafyuh.dev/mafyuh/Auto-Homelab), [Iac-Homelab](https://git.mafyuh.dev/mafyuh/IaC-Homelab), [ansible-playbooks](https://git.mafyuh.dev/mafyuh/ansible-playbooks) and [kub](https://git.mafyuh.dev/mafyuh/kub) repos into this one.
ToDo
- [ ] Update Readme
- [ ] Migrate all containers to use this repo (DB migrations)
- [x] Get OpenTofu migrated to this repo
- [ ] Get Kubernetes repo migrated over
- [ ] Re-bootstrap Flux

View file

@ -1,33 +0,0 @@
---
- name: Deploy application
hosts: "{{ target_host }}"
vars:
repo_path: "/home/{{ ansible_user }}/iac/{{ folder }}"
tasks:
- name: Ensure the repository is up-to-date
shell: git pull
args:
chdir: "{{ repo_path }}"
register: git_pull_output
- name: Display git pull output
debug:
var: git_pull_output.stdout_lines
- name: Restart services
command: docker compose up -d
args:
chdir: "{{ repo_path }}"
register: docker_compose_output
- name: Display docker output
debug:
var: docker_compose_output.stdout_lines
- name: Run Docker Command
command: docker ps
register: docker_output
- name: Display Docker Output
debug:
var: docker_output.stdout_lines

View file

@ -3,7 +3,7 @@
<div align="center">
# IaC
# IaC-Homelab
Infrastructure as Code (IaC) for my homelab using OpenTofu.