115 lines
4.1 KiB
YAML
115 lines
4.1 KiB
YAML
name: Validate DAGs
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- "app-configs/rinoa/dagu/dags/**"
|
|
branches-ignore:
|
|
- main
|
|
|
|
env:
|
|
DAGS_PATH: "app-configs/rinoa/dagu/dags"
|
|
VAULT_ADDR: ${{ secrets.TREZ_VAULT_ADDR }}
|
|
VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
|
|
|
|
jobs:
|
|
validate-dags:
|
|
name: DAGU DAG(s) Validation
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@0.0.3
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Dagu Validation"
|
|
notification_message: "Setting up Ansible and Vault... 🏗️"
|
|
|
|
- name: Install Ansible
|
|
uses: alex-oleshkevich/setup-ansible@f879ce3cf11a7315e130919a797526b0c6bfd272 # v1.0.1
|
|
with:
|
|
version: "11.4.0"
|
|
|
|
- name: Cache Ansible Galaxy Collections
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: collections
|
|
key: ${{ runner.os }}-ansible-${{ hashFiles('./collections/requirements.yml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-ansible-
|
|
|
|
- name: Set up Vault CLI
|
|
uses: eLco/setup-vault@5d0ddffdfca9650484ae1378dafc376a9ebcd15e # v1.0.3
|
|
with:
|
|
vault_version: 1.18.0
|
|
|
|
- name: Cache pip
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install hvac (Vault Python SDK)
|
|
run: pip install hvac
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@0.0.3
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Dagu Validation"
|
|
notification_message: "Ansible and Vault setups completed, starting Dagu validation... 🔬"
|
|
|
|
- name: Install dagu
|
|
run: |
|
|
curl -L https://raw.githubusercontent.com/dagu-org/dagu/main/scripts/installer.sh | bash
|
|
|
|
- name: Render DAG Jinja templates
|
|
uses: dawidd6/action-ansible-playbook@c97d71562fcba83cc1ea0602d5a77013427f7571 # v2.8.0
|
|
with:
|
|
directory: .
|
|
vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
|
|
requirements: collections/requirements.yml
|
|
playbook: rinoa-render-dags.yml
|
|
|
|
- name: Validate DAGs
|
|
run: |
|
|
for dag in $(find ${DAGS_PATH} -type f -name "*.yaml" -a ! -name "*example*"); do
|
|
echo -e "\n\n===========Validating ${dag}===========\n"
|
|
dagu dry "${dag}"
|
|
done
|
|
echo "exit_code=$status" >> $GITHUB_OUTPUT
|
|
|
|
- name: Gotify Notification
|
|
if: steps.validate-dags.outputs.exit_code == '0'
|
|
uses: eikendev/gotify-action@0.0.3
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Dagu Validation"
|
|
notification_message: "Dagu DAG validation passed! 🏁"
|
|
|
|
- name: Gotify Notification
|
|
if: steps.validate-dags.outputs.exit_code != '0'
|
|
uses: eikendev/gotify-action@0.0.3
|
|
with:
|
|
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
|
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
|
notification_title: "GITEA: Dagu Validation"
|
|
notification_message: "Dagu DAG validation failed! 🚫"
|
|
|
|
- name: Trigger Tar Valon Ansible Deploy
|
|
run: |
|
|
BRANCH="${GITHUB_REF_NAME}"
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.BOT_GITEA_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"https://git.trez.wtf/api/v1/repos/Trez/tar-valon-ansible/actions/workflows/gitea_tar-valon_ansible_deploy.yml/dispatches" \
|
|
-d "{\"ref\":\"${BRANCH}\"}"
|