Skip to content

Commit

Permalink
Rui関連のファイルが変更された場合にansibleを回せるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
cradle8810 committed Apr 25, 2024
1 parent 8cb45ba commit d9384d4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/dnsmasq-exec.yml

This file was deleted.

46 changes: 45 additions & 1 deletion .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- '**'
workflow_dispatch:

jobs:
Yamllint:
Expand Down Expand Up @@ -38,11 +39,31 @@ jobs:
"./dupcheck.sh"
"inventories/host_vars/rui/ads_hosts/NXDOMAIN.yml"
Ansible-rui-dns:
Detect_File_Changed:
runs-on: ubuntu-latest
outputs:
rui: ${{ steps.changes.outputs.rui }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check What file were changed
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
rui:
- 'rui.yml'
- 'tasks/rui/dnsmasq.yml'
- 'inventories/host_vars/rui/**'
Dry_Run_ansible:
if: ${{ needs.Detect_File_Changed.outputs.rui == 'true' }}
needs:
- Yamllint
- AnsibleLint
- Duplicate_Check
- Detect_File_Changed
runs-on: self-hosted
steps:
- name: Checkout
Expand All @@ -61,3 +82,26 @@ jobs:
--ssh-extra-args='-o StrictHostKeyChecking=no' \
--extra-vars "ansible_sudo_pass=${{ secrets.SUDO }}" \
rui.yml
Run_ansible:
# if file for rui changed and master branch
if: "${{ needs.Detect_File_Changed.outputs.rui == 'true' && github.ref == 'refs/heads/master'}}"
needs:
- Dry_Run_ansible
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Prepare environments (ansible-galaxy)
run: |
ansible-galaxy install -r requirements.yml
- name: "ansible-playbook --tags dnsmasq rui.yml"
run: |
ansible-playbook \
-i inventories \
--tags dnsmasq \
--ssh-extra-args='-o StrictHostKeyChecking=no' \
--extra-vars "ansible_sudo_pass=${{ secrets.SUDO }}" \
rui.yml
3 changes: 3 additions & 0 deletions inventories/host_vars/rui/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
a:
- a.yml

0 comments on commit d9384d4

Please sign in to comment.