dns/.forgejo/workflows/ci.yaml

62 lines
2.0 KiB
YAML

on:
push:
branches:
- 'main'
jobs:
sync:
runs-on: linux_amd64
steps:
- name: Retrieve and sync files
shell: bash
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }} dns
echo "Cloned sucessfully from ${{ gitea.server_url }}/${{ gitea.repository }}"
cd dns
echo "" > /var/cache/bind/.modified
if [ -z $(git diff-tree --no-commit-id --name-only -r main | grep '*.zone') ]; then
exit 0
fi
files=$(git diff-tree --no-commit-id --name-only -r main | grep '*.zone')
echo "Have to test $files"
for file in $files
do
domain=$(echo $file | sed "s/.zone//g")
/usr/sbin/named-checkzone "$domain" "$file" || echo "Error on file $file" && continue
echo "$file" >> /var/cache/bind/.modified
cp -f "$file" "/var/cache/bind/$file"
done
echo "Synced sucessfully"
deploiement:
runs-on: linux_amd64
needs: sync
steps:
- name: Reload bind
shell: bash
run: |
sudo systemctl reload bind9.service
- name: Check bind
shell: bash
run: |
echo Recherche de zones déployées
cd /var/cache/bind
files=$(cat /var/cache/bind/.modified)
if [ -z $files ]; then
exit 0
fi
count=$(cat /var/cache/bind/.modified | wc -l)
linecount=$(( count * 5 + 3))
echo "Vérification des zones $files..."
sudo grep named /var/log/syslog | tail -n $linecount | grep "reloading configuration succeeded" || exit 4
sudo grep named /var/log/syslog | tail -n $linecount | grep "reloading zones succeeded" || exit 5
sudo grep named /var/log/syslog | tail -n $linecount | grep "all zones loaded" || exit 6
sudo grep named /var/log/syslog | tail -n $linecount | grep "running" || exit 7
echo "Déploiement terminé."