diff --git a/.github/workflows/dnsmasq-exec.yml b/.github/workflows/dnsmasq-exec.yml deleted file mode 100644 index a0913a2..0000000 --- a/.github/workflows/dnsmasq-exec.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Update DNS for rui - -on: - workflow_run: - workflows: ["AnsibleLint"] - types: ["completed"] - -jobs: - Dryrun: - runs-on: self-hosted - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: "ansible-play -C --tags dnsmasq rui.yml" - run: | - ansible-playbook \ - -i inventories -C \ - --tags dnsmasq \ - rui.yml diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index a97eed5..77f3b81 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -4,6 +4,7 @@ on: push: branches: - '**' + workflow_dispatch: jobs: Yamllint: @@ -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 @@ -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 diff --git a/inventories/host_vars/rui/test.yml b/inventories/host_vars/rui/test.yml new file mode 100644 index 0000000..60fc2fe --- /dev/null +++ b/inventories/host_vars/rui/test.yml @@ -0,0 +1,3 @@ +--- +a: + - a.yml