dns/.forgejo/workflows/ci.yaml

67 lines
2.1 KiB
YAML
Raw Normal View History

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:
tests-and-sync:
runs-on: linux_amd64
steps:
- name: Retrieve files
shell: bash
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }} dns
- name: Test files
shell: bash
run: |
cd dns
2023-10-25 00:53:50 +02:00
files=$(git diff-tree --no-commit-id --name-only -r main | grep "*.zone")
2023-10-24 18:04:11 +02:00
for file in $files
do
domain=$(echo $file | sed "s/.zone//g")
2023-10-25 00:55:43 +02:00
/usr/sbin/named-checkzone "$domain" "$file" || exit 2 && echo "Error on file $file"
2023-10-24 18:04:11 +02:00
done
2023-10-25 00:53:50 +02:00
echo $(git diff-tree --no-commit-id --name-only -r main | grep "*.zone") > /var/cache/bind/.modified
2023-10-24 18:04:11 +02:00
sync:
runs-on: linux_amd64
steps:
- name: Retrieve files
shell: bash
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }} dns
- name: Sync files
shell: bash
run: |
cd dns
files=$(cat /var/cache/bind/.modified)
if [ -z "$files" ]; then
files=$(find . -name "*.zone" -printf %P)
fi
for file in $files
do
cp -f "$file" "/var/cache/bind/$file"
done
deploiement:
runs-on: linux_amd64
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
cd /var/cache/bind/.modified
files=$(cat /var/cache/bind/.modified)
count=$(cat /var/cache/bind/.modified | wc -l)
linecount=$(( count * 5 + 3))
2023-10-25 00:35:17 +02:00
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
2023-10-25 00:40:10 +02:00
echo "Déploiement terminé."