dns/.forgejo/workflows/ci.yaml

63 lines
1.8 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)
for file in $files
do
domain=$(echo $file | sed "s/.zone//g")
/usr/bin/named-checkzone "$domain" "$file" || ( echo "Error on file $file" && continue; )
echo "$file" >> /var/cache/bind/.modified
rsync "$file" /var/cache/bind/
echo "Move $file to /var/cache/bind"
done
sudo chown bind:bind /var/cache/bind/*.zone
sudo chmod g+rw /var/cache/bind/*.zone
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
echo Aucune zone déployée
exit 0
fi
for zone_name in $files; do
datetime=$(date --iso-8601=seconds)
echo "Vérification de la zone $domain..."
sudo grep named /var/log/syslog | grep ${datetime::-10} | grep ${zone_name::-5} | grep loaded || exit 1
echo "Déploiement terminé !"