kovalhome/.github/workflows/infra.yaml

54 lines
1.4 KiB
YAML
Raw Normal View History

2023-08-28 22:59:57 +00:00
name: Infrastructure
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- infra/**
paths:
- infra/**-playbook.yaml
- .github/workflows/infra.yaml
2023-08-29 01:11:53 +00:00
fork:
2023-08-28 22:59:57 +00:00
jobs:
check:
name: Check infrastructure definitions
runs-on: ubuntu-latest
steps:
2023-08-29 01:42:18 +00:00
- name: Checkout
2023-08-29 01:28:49 +00:00
uses: actions/checkout@v3
2023-08-29 01:51:52 +00:00
with:
fetch-depth: 2
2023-08-29 01:36:53 +00:00
2023-08-29 01:47:32 +00:00
- name: Fetch PR base
if: github.event.pull_request
2023-08-29 01:42:18 +00:00
run: |
2023-08-29 01:47:32 +00:00
git fetch --no-tags --progress --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.sha }}
2023-08-28 22:59:57 +00:00
- name: Setup Python
uses: actions/setup-python@v4
with:
2023-08-28 23:45:24 +00:00
python-version: "3.11"
2023-08-28 22:59:57 +00:00
- name: Install dependencies
2023-08-28 23:16:13 +00:00
run: |
2023-08-29 01:13:40 +00:00
pip3 install -r requirements.txt
ansible-galaxy collection install community.general
2023-08-28 22:59:57 +00:00
- name: Get changed playbooks
id: changed-playbooks
uses: tj-actions/changed-files@v38
with:
2023-08-29 01:47:32 +00:00
base_sha: ${{ github.event.pull_request.base.sha }}
2023-08-28 22:59:57 +00:00
files: infra/**-playbook.yaml
- name: Check modified playbooks
2023-08-28 23:16:13 +00:00
run: |
2023-08-29 01:51:52 +00:00
echo "Got changed files: '${{ steps.changed-playbooks.outputs.all_changed_files }}'"
2023-08-28 22:59:57 +00:00
for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do
ansible --inventory ./inventory --check "$file"
done