done?
This commit is contained in:
parent
3a06da378d
commit
3472e41360
|
@ -11,6 +11,7 @@ on:
|
||||||
paths:
|
paths:
|
||||||
- infra/**-playbook.yaml
|
- infra/**-playbook.yaml
|
||||||
- .github/workflows/infra.yaml
|
- .github/workflows/infra.yaml
|
||||||
|
fork:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
|
@ -19,13 +20,6 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
|
|
||||||
- name: Fetch PR base
|
|
||||||
if: github.event.pull_request
|
|
||||||
run: |
|
|
||||||
git fetch --no-tags --progress --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.sha }}
|
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
|
@ -37,12 +31,34 @@ jobs:
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
ansible-galaxy collection install community.general
|
ansible-galaxy collection install community.general
|
||||||
|
|
||||||
- name: Get changed playbooks
|
|
||||||
id: changed-playbooks
|
|
||||||
run: |
|
|
||||||
git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | base64 | xargs -I {} echo "files_b64={}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Check modified playbooks
|
- name: Check modified playbooks
|
||||||
run: |
|
run: |
|
||||||
export FILES="${{ steps.changed-playbooks.outputs.files_b64 }}"
|
find . -wholename "*/infra/*-playbook.yaml" -type f -exec ansible-playbook --inventory ./inventory --check {} \;
|
||||||
echo "Got changed files: '$(echo $FILES | base64 -d | xargs echo)'"
|
deploy:
|
||||||
|
name: Deploy modified infrastructure
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
ansible-galaxy collection install community.general
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: files
|
||||||
|
uses: tj-actions/changed-files@v38
|
||||||
|
|
||||||
|
- name: Run changed playbooks
|
||||||
|
run: |
|
||||||
|
for file in ${{ steps.files.outputs.all_changed_files }}; do
|
||||||
|
ansible-playbook --inventory ./inventory "$file"
|
||||||
|
done
|
||||||
|
|
|
@ -8,5 +8,6 @@ proxmox:
|
||||||
pve2.mgmt.home.local.koval.net:
|
pve2.mgmt.home.local.koval.net:
|
||||||
managed:
|
managed:
|
||||||
hosts:
|
hosts:
|
||||||
|
test-vm.mgmt.home.local.koval.net:
|
||||||
unmanaged:
|
unmanaged:
|
||||||
hosts:
|
hosts:
|
||||||
|
|
Loading…
Reference in New Issue