From c918e5761cc5297caced4feceb1d720f9d121051 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Mon, 28 Aug 2023 23:59:57 +0100 Subject: [PATCH 01/26] initial --- .github/workflows/infra.yaml | 45 +++++++++++++++++++++++++++++ infra/test-vm/proxmox-playbook.yaml | 24 +++++++++++++++ inventory/proxmox.yaml | 12 ++++++++ 3 files changed, 81 insertions(+) create mode 100644 .github/workflows/infra.yaml create mode 100644 infra/test-vm/proxmox-playbook.yaml create mode 100644 inventory/proxmox.yaml diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml new file mode 100644 index 0000000..52c9251 --- /dev/null +++ b/.github/workflows/infra.yaml @@ -0,0 +1,45 @@ +name: Infrastructure +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - infra/** + paths: + - infra/**-playbook.yaml + - .github/workflows/infra.yaml + +jobs: + check: + name: Check infrastructure definitions + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: -| + python3 -m venv venv + source venv/bin/activate + pip3 install -r requirements.txt + ansible-galaxy collection install community.general + + - name: Get changed playbooks + id: changed-playbooks + uses: tj-actions/changed-files@v38 + with: + files: infra/**-playbook.yaml + + - name: Check modified playbooks + run: -| + for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do + ansible --inventory ./inventory --check "$file" + done diff --git a/infra/test-vm/proxmox-playbook.yaml b/infra/test-vm/proxmox-playbook.yaml new file mode 100644 index 0000000..e8c20bf --- /dev/null +++ b/infra/test-vm/proxmox-playbook.yaml @@ -0,0 +1,24 @@ +- name: Proxmox test-vm + hosts: localhost + module_defaults: + community.general.proxmox_kvm: + api_user: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('!.*') }}" + api_host: "{{ lookup('ansible.builtin.env', 'PROXMOX_HOST' ) }}" + api_token_id: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('.*!') }}" + api_token_secret: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_SECRET') }}" + name: test-vm + node: pve + tasks: + - name: Create test-vm + community.general.proxmox_kvm: + name: test-vm + node: pve + - name: Update test-vm + community.general.proxmox_kvm: + cpu: x86-64-v3 + memory: 2048 + cores: 3 + update: true + - name: Start test-vm + community.general.proxmox_kvm: + state: started diff --git a/inventory/proxmox.yaml b/inventory/proxmox.yaml new file mode 100644 index 0000000..6b4033d --- /dev/null +++ b/inventory/proxmox.yaml @@ -0,0 +1,12 @@ +proxmox: + children: + kovalhome: + children: + nodes: + hosts: + pve.mgmt.home.local.koval.net: + pve2.mgmt.home.local.koval.net: + managed: + hosts: + unmanaged: + hosts: -- 2.40.1 From 6e29e43ac038b05c2d18a8ef0d3c4b9ce557e4c1 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:04:15 +0100 Subject: [PATCH 02/26] fix setup python --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 52c9251..b5be677 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: ">=3.11" - name: Install dependencies run: -| -- 2.40.1 From eb68d6529f609b7ee2830adcd80ca03ab71199da Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:10:57 +0100 Subject: [PATCH 03/26] testing --- .github/workflows/infra.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index b5be677..a3b24d7 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,6 +20,9 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - run: -| + uname -a + lsb_release -a - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From fe43f55a4868e759cde1e64cdbd9dab8cbf4018b Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:16:13 +0100 Subject: [PATCH 04/26] uhhh --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index a3b24d7..327be7b 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,7 +20,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - run: -| + - run: | uname -a lsb_release -a - name: Setup Python @@ -29,7 +29,7 @@ jobs: python-version: ">=3.11" - name: Install dependencies - run: -| + run: | python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt @@ -42,7 +42,7 @@ jobs: files: infra/**-playbook.yaml - name: Check modified playbooks - run: -| + run: | for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do ansible --inventory ./inventory --check "$file" done -- 2.40.1 From 6a83fdf3790e5f6033b408672e7f5d59713a7de0 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:30:10 +0100 Subject: [PATCH 05/26] fix? --- .github/workflows/infra.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 327be7b..1a9b7d9 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -21,8 +21,7 @@ jobs: uses: actions/checkout@v3 - run: | - uname -a - lsb_release -a + apt install lsb-release - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From 47c06b02f9e4347b3b733f70bbdd48dc0faae4e0 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:41:34 +0100 Subject: [PATCH 06/26] remove install lsb_release --- .github/workflows/infra.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 1a9b7d9..648bca8 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,8 +20,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - run: | - apt install lsb-release - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From f9b321367bc8a007398ac22ce2f0b7adabb702b9 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:45:24 +0100 Subject: [PATCH 07/26] trigger ci --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 648bca8..25206d6 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: ">=3.11" + python-version: "3.11" - name: Install dependencies run: | -- 2.40.1 From d143ffc123f2d3df4ed54cb4c9f8ce63e4f7a321 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:30:44 +0100 Subject: [PATCH 08/26] don't use venv --- .github/workflows/infra.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 25206d6..37f3ad0 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -27,8 +27,6 @@ jobs: - name: Install dependencies run: | - python3 -m venv venv - source venv/bin/activate pip3 install -r requirements.txt ansible-galaxy collection install community.general -- 2.40.1 From 7b7f9f5999f9761aba2a002ce9a67dc9ac4bcbac Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:44:10 +0100 Subject: [PATCH 09/26] idek --- .github/workflows/infra.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 37f3ad0..4b28db4 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -34,6 +34,7 @@ jobs: id: changed-playbooks uses: tj-actions/changed-files@v38 with: + since_last_remote_commit: "true" files: infra/**-playbook.yaml - name: Check modified playbooks -- 2.40.1 From e9559c939ab8752957eceec7cb6762c96993c54f Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:56:06 +0100 Subject: [PATCH 10/26] fix checkout? --- .github/workflows/infra.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 4b28db4..9c1f097 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From f3c68d9ecbd26d8a39d346b08b9f03fd1b84cb76 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:11:53 +0100 Subject: [PATCH 11/26] testing stuff --- .github/workflows/infra.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 9c1f097..86aef50 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -11,6 +11,7 @@ on: paths: - infra/**-playbook.yaml - .github/workflows/infra.yaml + fork: jobs: check: @@ -19,8 +20,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 2 + + - run: | + echo ${{ github.event.pull_request.commits }} + echo ${{ github.event.pusher }} + echo ${{ github.event.forkee }} - name: Setup Python uses: actions/setup-python@v4 @@ -29,8 +33,8 @@ jobs: - name: Install dependencies run: | - pip3 install -r requirements.txt - ansible-galaxy collection install community.general + pip3 install -r requirements.txt ${{ github.event.pull_request.base }} + ansible-galaxy collection install community.general ${{ github.event.pull_request.merge_commit_sha }} - name: Get changed playbooks id: changed-playbooks -- 2.40.1 From d17f76ba6dcad4a33c637c50d08d54b283e294da Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:12:29 +0100 Subject: [PATCH 12/26] checking more stuff --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 86aef50..3c20a3b 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,9 +22,9 @@ jobs: uses: actions/checkout@v3 - run: | - echo ${{ github.event.pull_request.commits }} - echo ${{ github.event.pusher }} - echo ${{ github.event.forkee }} + echo !${{ github.event.pull_request.commits }} + echo !${{ github.event.pusher }} + echo !${{ github.event.forkee }} - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From 6e1217c9e8edbc53bb86ff2f7ed3c350890e63fd Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:13:40 +0100 Subject: [PATCH 13/26] maybe --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 3c20a3b..7063770 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - run: | - echo !${{ github.event.pull_request.commits }} + echo !${{ github.event.pull_request }} echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} @@ -33,8 +33,8 @@ jobs: - name: Install dependencies run: | - pip3 install -r requirements.txt ${{ github.event.pull_request.base }} - ansible-galaxy collection install community.general ${{ github.event.pull_request.merge_commit_sha }} + pip3 install -r requirements.txt + ansible-galaxy collection install community.general - name: Get changed playbooks id: changed-playbooks -- 2.40.1 From c8c624e82b362cb991f8af30850f432f7b92a473 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:14:45 +0100 Subject: [PATCH 14/26] more checking --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 7063770..aa327d0 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - run: | - echo !${{ github.event.pull_request }} + echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} -- 2.40.1 From 6e4661baaf14cbad0ae947606ee07d4a3b426cfd Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:24:41 +0100 Subject: [PATCH 15/26] more logging --- .github/workflows/infra.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index aa327d0..b201155 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -25,6 +25,7 @@ jobs: echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} + git remote get-url origin - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From 206b1b3be48ac357f8f25b9f86e14bd8f2abf318 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:25:57 +0100 Subject: [PATCH 16/26] huh --- .github/workflows/infra.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index b201155..11388dc 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -26,6 +26,7 @@ jobs: echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} git remote get-url origin + git branch -l | cat - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From c3f519e87d6edb039473fa41c7d56c37a8017b31 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:28:49 +0100 Subject: [PATCH 17/26] maybe maybe maybe --- .github/workflows/infra.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 11388dc..6f5d0db 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -18,6 +18,10 @@ jobs: name: Check infrastructure definitions runs-on: ubuntu-latest steps: + - name: Checkout target + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.base.ref }} - name: Checkout uses: actions/checkout@v3 -- 2.40.1 From 53b0f1249572d4df56f24163e3f2e850f004ff79 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:36:53 +0100 Subject: [PATCH 18/26] don't clean --- .github/workflows/infra.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 6f5d0db..c96fbd7 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,8 +22,11 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.base.ref }} - - name: Checkout + + - name: Checkout PR uses: actions/checkout@v3 + with: + clean: false - run: | echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} -- 2.40.1 From 964a1ff59b3b48d4132f074ece5591f89de33ad6 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:42:18 +0100 Subject: [PATCH 19/26] fix? --- .github/workflows/infra.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index c96fbd7..fbec85c 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -18,15 +18,12 @@ jobs: name: Check infrastructure definitions runs-on: ubuntu-latest steps: - - name: Checkout target + - name: Checkout uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.base.ref }} - - name: Checkout PR - uses: actions/checkout@v3 - with: - clean: false + - name: Fetch target + run: | + git fetch --no-tags --progress --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.ref }} - run: | echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} -- 2.40.1 From 01d6f01d563ec7ee7cca89d450c200f0ce424bea Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:47:32 +0100 Subject: [PATCH 20/26] probably fixed --- .github/workflows/infra.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index fbec85c..fa937da 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -21,9 +21,14 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Fetch target + - 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.ref }} + git fetch --no-tags --progress --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.sha }} + + - name: Test + if: github.event.forkee + run: echo dot! - run: | echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} @@ -46,7 +51,7 @@ jobs: id: changed-playbooks uses: tj-actions/changed-files@v38 with: - since_last_remote_commit: "true" + base_sha: ${{ github.event.pull_request.base.sha }} files: infra/**-playbook.yaml - name: Check modified playbooks -- 2.40.1 From b75d285263a5a7860008a86701b1d78954e6b0ea Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:51:52 +0100 Subject: [PATCH 21/26] wut --- .github/workflows/infra.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index fa937da..71aa20a 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,22 +20,13 @@ jobs: steps: - name: Checkout 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: Test - if: github.event.forkee - run: echo dot! - - - run: | - echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} - echo !${{ github.event.pusher }} - echo !${{ github.event.forkee }} - git remote get-url origin - git branch -l | cat - name: Setup Python uses: actions/setup-python@v4 @@ -56,6 +47,7 @@ jobs: - name: Check modified playbooks run: | + echo "Got changed files: '${{ steps.changed-playbooks.outputs.all_changed_files }}'" for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do ansible --inventory ./inventory --check "$file" done -- 2.40.1 From 2a68bca401b8540b2e1b1a388d701c213a60e8c9 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:57:04 +0100 Subject: [PATCH 22/26] remove fork --- .github/workflows/infra.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 71aa20a..1ec00f9 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -11,7 +11,6 @@ on: paths: - infra/**-playbook.yaml - .github/workflows/infra.yaml - fork: jobs: check: -- 2.40.1 From 120cede54ec3effba3dc71ef88611740d919434e Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 03:10:47 +0100 Subject: [PATCH 23/26] custom --- .github/workflows/infra.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 1ec00f9..5f4e516 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -39,14 +39,10 @@ jobs: - name: Get changed playbooks id: changed-playbooks - uses: tj-actions/changed-files@v38 - with: - base_sha: ${{ github.event.pull_request.base.sha }} - files: infra/**-playbook.yaml + run: | + git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | base64 | xargs -I {} echo "files_b64={}" >> "$GITHUB_OUTPUT" - name: Check modified playbooks run: | - echo "Got changed files: '${{ steps.changed-playbooks.outputs.all_changed_files }}'" - for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do - ansible --inventory ./inventory --check "$file" - done + export FILES="${{ steps.changed-playbooks.outputs.files_b64 }}" + echo "Got changed files: '$(echo $FILES | base64 -d | xargs echo)'" -- 2.40.1 From 3a06da378d0a191e0f7ced450cc2578e9389eed5 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 03:11:16 +0100 Subject: [PATCH 24/26] test --- README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 7f0e2bd..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# KovalHome (and koval.net) infrastructure -- 2.40.1 From 3472e413608c7e075891a7447b5ccfc6e33f5a02 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sat, 2 Sep 2023 18:47:53 +0100 Subject: [PATCH 25/26] done? --- .github/workflows/infra.yaml | 44 ++++++++++++++++++++++++------------ inventory/proxmox.yaml | 1 + 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 5f4e516..f87af7b 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -11,6 +11,7 @@ on: paths: - infra/**-playbook.yaml - .github/workflows/infra.yaml + fork: jobs: check: @@ -19,13 +20,6 @@ jobs: steps: - name: Checkout 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 uses: actions/setup-python@v4 @@ -37,12 +31,34 @@ jobs: pip3 install -r requirements.txt 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 run: | - export FILES="${{ steps.changed-playbooks.outputs.files_b64 }}" - echo "Got changed files: '$(echo $FILES | base64 -d | xargs echo)'" + find . -wholename "*/infra/*-playbook.yaml" -type f -exec ansible-playbook --inventory ./inventory --check {} \; + 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 diff --git a/inventory/proxmox.yaml b/inventory/proxmox.yaml index 6b4033d..ff90334 100644 --- a/inventory/proxmox.yaml +++ b/inventory/proxmox.yaml @@ -8,5 +8,6 @@ proxmox: pve2.mgmt.home.local.koval.net: managed: hosts: + test-vm.mgmt.home.local.koval.net: unmanaged: hosts: -- 2.40.1 From f2857948779c9fe31898f3816c8beeb3c35f5ba2 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sat, 2 Sep 2023 18:49:51 +0100 Subject: [PATCH 26/26] only run deployment on master --- .github/workflows/infra.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index f87af7b..b0b971a 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -37,6 +37,7 @@ jobs: deploy: name: Deploy modified infrastructure runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v3 -- 2.40.1