kovalhome/.github/workflows/infra.yaml

66 lines
1.6 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-09-02 17:47: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-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
2023-09-02 17:47:53 +00:00
- name: Check modified playbooks
2023-08-29 02:10:47 +00:00
run: |
2023-09-02 17:47:53 +00:00
find . -wholename "*/infra/*-playbook.yaml" -type f -exec ansible-playbook --inventory ./inventory --check {} \;
deploy:
name: Deploy modified infrastructure
runs-on: ubuntu-latest
2023-09-02 17:49:51 +00:00
if: github.ref == 'refs/heads/main'
2023-09-02 17:47:53 +00:00
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
2023-08-28 22:59:57 +00:00
2023-09-02 17:47:53 +00:00
- 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
2023-08-28 23:16:13 +00:00
run: |
2023-09-02 17:47:53 +00:00
for file in ${{ steps.files.outputs.all_changed_files }}; do
ansible-playbook --inventory ./inventory "$file"
done