Files
LeDiscord/.gitea/workflows/deploy-prod.yml
EvanChal 7325f25b5f
Some checks failed
Deploy to Production / build-and-deploy (push) Failing after 2s
ci/cd update 5
2025-12-24 03:45:04 +01:00

49 lines
2.4 KiB
YAML

name: Deploy to Production
on:
push:
branches:
- prod
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure DNS
run: |
echo "nameserver 192.168.1.50" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "DNS configured:"
cat /etc/resolv.conf
# Ajouter l'IP du registry à /etc/hosts si disponible
if [ -n "${{ secrets.REGISTRY_IP }}" ]; then
echo "${{ secrets.REGISTRY_IP }} ${{ secrets.REGISTRY_URL }}" >> /etc/hosts
echo "Added to /etc/hosts: ${{ secrets.REGISTRY_IP }} ${{ secrets.REGISTRY_URL }}"
fi
# Tester la résolution DNS
echo "Testing DNS resolution..."
getent hosts ${{ secrets.REGISTRY_URL }} || echo "DNS resolution test"
- name: Login to Gitea Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin
- name: Build and push
run: |
echo "Building backend image..."
docker build --dns 192.168.1.50 --dns 8.8.8.8 -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ./backend
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend
echo "Pushing backend images..."
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-backend
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-backend
echo "Building frontend image..."
docker build --dns 192.168.1.50 --dns 8.8.8.8 -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ./frontend
docker tag ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend
echo "Pushing frontend images..."
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:prod-frontend
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/lediscord:latest-frontend