2023-10-24 18:04:11 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-10-25 00:53:02 +02:00
|
|
|
- 'main'
|
2023-10-24 18:04:11 +02:00
|
|
|
|
|
|
|
jobs:
|
2023-11-30 18:26:23 +01:00
|
|
|
sync:
|
2023-10-24 18:04:11 +02:00
|
|
|
runs-on: linux_amd64
|
|
|
|
steps:
|
2023-11-30 18:26:23 +01:00
|
|
|
- name: Retrieve and sync files
|
2023-10-24 18:04:11 +02:00
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }} dns
|
2023-11-30 17:56:32 +01:00
|
|
|
echo "Cloned sucessfully from ${{ gitea.server_url }}/${{ gitea.repository }}"
|
2023-11-30 18:30:05 +01:00
|
|
|
cd dns
|
2023-11-30 18:54:05 +01:00
|
|
|
echo "" > /var/cache/bind/.modified
|
2023-11-30 18:48:57 +01:00
|
|
|
|
2023-11-30 20:34:52 +01:00
|
|
|
if [ -z $(git diff-tree --no-commit-id --name-only -r main | grep zone) ]; then
|
2023-11-30 18:48:57 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-11-30 20:34:52 +01:00
|
|
|
files=$(git diff-tree --no-commit-id --name-only -r main | grep zone)
|
2023-11-30 18:48:57 +01:00
|
|
|
|
2023-10-24 18:04:11 +02:00
|
|
|
for file in $files
|
|
|
|
do
|
|
|
|
domain=$(echo $file | sed "s/.zone//g")
|
2023-11-30 20:43:55 +01:00
|
|
|
/usr/bin/named-checkzone "$domain" "$file" || ( echo "Error on file $file" && continue; )
|
2023-11-30 18:26:23 +01:00
|
|
|
echo "$file" >> /var/cache/bind/.modified
|
2024-04-24 15:08:10 +02:00
|
|
|
rsync "./$file" /var/cache/bind/
|
2023-11-30 20:39:19 +01:00
|
|
|
echo "Move $file to /var/cache/bind"
|
2023-10-24 18:04:11 +02:00
|
|
|
done
|
2023-11-30 21:10:41 +01:00
|
|
|
sudo chown bind:bind /var/cache/bind/*.zone
|
|
|
|
sudo chmod g+rw /var/cache/bind/*.zone
|
2023-11-30 18:26:23 +01:00
|
|
|
echo "Synced sucessfully"
|
|
|
|
|
2023-10-24 18:04:11 +02:00
|
|
|
|
|
|
|
deploiement:
|
|
|
|
runs-on: linux_amd64
|
2023-10-28 18:44:06 +02:00
|
|
|
needs: sync
|
2023-10-24 18:04:11 +02:00
|
|
|
steps:
|
|
|
|
- name: Reload bind
|
|
|
|
shell: bash
|
2023-10-25 00:35:17 +02:00
|
|
|
run: |
|
|
|
|
sudo systemctl reload bind9.service
|
2023-10-24 18:04:11 +02:00
|
|
|
- name: Check bind
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo Recherche de zones déployées
|
2023-11-30 18:59:22 +01:00
|
|
|
cd /var/cache/bind
|
2023-10-24 18:04:11 +02:00
|
|
|
files=$(cat /var/cache/bind/.modified)
|
2023-11-30 19:00:30 +01:00
|
|
|
|
|
|
|
if [ -z $files ]; then
|
2024-04-24 14:59:32 +02:00
|
|
|
echo Aucune zone déployée
|
|
|
|
exit 0
|
2023-11-30 19:00:30 +01:00
|
|
|
fi
|
|
|
|
|
2024-04-24 14:58:39 +02:00
|
|
|
for zone_name in $files; do
|
|
|
|
datetime=$(date --iso-8601=seconds)
|
2024-04-24 15:10:17 +02:00
|
|
|
echo "Vérification de la zone ${zone_name::-5}..."
|
2024-04-24 15:12:36 +02:00
|
|
|
|
2024-04-24 15:20:03 +02:00
|
|
|
if [[ $zone_name == *":"* ]]; then
|
2024-04-24 15:19:37 +02:00
|
|
|
echo On ne sait pas vérifier ce type de zone
|
|
|
|
else
|
|
|
|
echo Dernière minute...
|
|
|
|
sudo grep named /var/log/syslog | grep ${datetime::-10} | grep ${zone_name::-5}
|
|
|
|
sudo grep named /var/log/syslog | grep ${datetime::-9} | grep ${zone_name::-5} | grep loaded || exit 1
|
|
|
|
fi
|
2024-04-24 15:01:51 +02:00
|
|
|
done
|
|
|
|
|
2024-04-03 17:14:11 +02:00
|
|
|
echo "Déploiement terminé !"
|