format github workflows

pull/20/head
Cian Hatton 3 years ago
parent 86c987aadc
commit f37e43ea74

@ -1,12 +1,11 @@
---
name: CI name: CI
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
env: env:
VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
SSH_PUB: "${{ secrets.SSH_PUB }}" SSH_PUB: ${{ secrets.SSH_PUB }}
ANSIBLE_FORCE_COLOR: '1' ANSIBLE_FORCE_COLOR: '1'
jobs: jobs:
@ -14,41 +13,41 @@ jobs:
name: Test Ansible Playbooks name: Test Ansible Playbooks
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create SSH pub - name: Create SSH pub
run: | run: |
echo "creating ~/.ssh/id_rsa.pub file" echo "creating ~/.ssh/id_rsa.pub file"
mkdir -p ~/.ssh/ mkdir -p ~/.ssh/
echo "$SSH_PUB" > ~/.ssh/id_rsa.pub echo "$SSH_PUB" > ~/.ssh/id_rsa.pub
- name: Install SSH key - name: Install SSH key
uses: shimataro/ssh-key-action@v2 uses: shimataro/ssh-key-action@v2
with: with:
key: ${{ secrets.SSH_KEY }} key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }} known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Check out the codebase. - name: Check out the codebase.
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Prepare Test Files - name: Prepare Test Files
run: | run: |
mv tests/.vault-pass.sh ./.vault-pass.sh mv tests/.vault-pass.sh ./.vault-pass.sh
mv tests/ansible.cfg ./ansible.cfg mv tests/ansible.cfg ./ansible.cfg
mv tests/hosts.ini ./hosts.ini mv tests/hosts.ini ./hosts.ini
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.8.9 python-version: 3.8.9
- name: Install test dependencies. - name: Install test dependencies.
run: pip install -r requirements.txt run: pip install -r requirements.txt
- name: Install ansible dependencies. - name: Install ansible dependencies.
run: ansible-galaxy install -r requirements.yml run: ansible-galaxy install -r requirements.yml
- name: Syntax Check - name: Syntax Check
run: | run: |
ansible-playbook setup-linode.yml --syntax-check ansible-playbook setup-linode.yml --syntax-check
ansible-playbook setup-homelab.yml --syntax-check ansible-playbook setup-homelab.yml --syntax-check
ansible-playbook verify-homelab.yml --syntax-check ansible-playbook verify-homelab.yml --syntax-check
- name: Setup Linode Instance - name: Setup Linode Instance
run: ansible-playbook setup-linode.yml run: ansible-playbook setup-linode.yml
- name: Setup Home Lab - name: Setup Home Lab
run: ansible-playbook setup-homelab.yml run: ansible-playbook setup-homelab.yml
- name: Verify Home Lab - name: Verify Home Lab
run: ansible-playbook verify-homelab.yml run: ansible-playbook verify-homelab.yml
- name: Delete Linode Instance - name: Delete Linode Instance
run: ansible-playbook setup-linode.yml --extra-vars "state=absent" run: ansible-playbook setup-linode.yml --extra-vars "state=absent"

@ -1,12 +1,11 @@
---
name: Delete test linode instance name: Delete test linode instance
on: on:
schedule: schedule:
- cron: "0 0 * * *" # delete at midnight every day - cron: 0 0 * * * # delete at midnight every day
env: env:
VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
SSH_PUB: "${{ secrets.SSH_PUB }}" SSH_PUB: ${{ secrets.SSH_PUB }}
ANSIBLE_FORCE_COLOR: '1' ANSIBLE_FORCE_COLOR: '1'
jobs: jobs:
@ -14,28 +13,28 @@ jobs:
name: Delete Linode Instance name: Delete Linode Instance
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create SSH pub - name: Create SSH pub
run: | run: |
echo "creating ~/.ssh/id_rsa.pub file" echo "creating ~/.ssh/id_rsa.pub file"
mkdir -p ~/.ssh/ mkdir -p ~/.ssh/
echo "$SSH_PUB" > ~/.ssh/id_rsa.pub echo "$SSH_PUB" > ~/.ssh/id_rsa.pub
- name: Install SSH key - name: Install SSH key
uses: shimataro/ssh-key-action@v2 uses: shimataro/ssh-key-action@v2
with: with:
key: ${{ secrets.SSH_KEY }} key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }} known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Check out the codebase. - name: Check out the codebase.
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Prepare Test Files - name: Prepare Test Files
run: | run: |
mv tests/.vault-pass.sh ./.vault-pass.sh mv tests/.vault-pass.sh ./.vault-pass.sh
mv tests/ansible.cfg ./ansible.cfg mv tests/ansible.cfg ./ansible.cfg
mv tests/hosts.ini ./hosts.ini mv tests/hosts.ini ./hosts.ini
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.8.9 python-version: 3.8.9
- name: Install test dependencies. - name: Install test dependencies.
run: pip install -r requirements.txt run: pip install -r requirements.txt
- name: Delete Linode Instance - name: Delete Linode Instance
run: ansible-playbook setup-linode.yml --extra-vars "state=absent" run: ansible-playbook setup-linode.yml --extra-vars "state=absent"

@ -1,7 +1,6 @@
--- name: Code Health
name: Lint
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
jobs: jobs:
@ -10,31 +9,31 @@ jobs:
strategy: strategy:
matrix: matrix:
directory: directory:
- roles - roles
- playbooks - playbooks
- group_vars - group_vars
- host_vars - host_vars
steps: steps:
- name: Checkout the codebase - name: Checkout the codebase
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.8.9 python-version: 3.8.9
- name: Install dependencies - name: Install dependencies
run: make deps run: make deps
- name: Test Directory - name: Test Directory
run: ansible-lint ${{ matrix.directory }} run: ansible-lint ${{ matrix.directory }}
format: format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the codebase - name: Checkout the codebase
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.8.9 python-version: 3.8.9
- name: Install dependencies - name: Install dependencies
run: make deps run: make deps
- name: Format code - name: Format code
run: make format run: make format

@ -13,3 +13,4 @@ format_dir roles
format_dir playbooks format_dir playbooks
format_dir host_vars format_dir host_vars
format_dir group_vars format_dir group_vars
format_dir .github/workflows

Loading…
Cancel
Save