fix: cicdl.yaml
Some checks failed
Build, Test and Deploy / test-backend (push) Successful in 12s
Build, Test and Deploy / build-and-push (push) Successful in 2m46s
Build, Test and Deploy / deploy (push) Failing after 3s

This commit is contained in:
2026-01-29 21:48:32 +01:00
parent 7fafabad42
commit 73fa36f9ec

View File

@@ -34,7 +34,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set TAG - name: Set TAG + OWNER lowercase
shell: bash shell: bash
run: | run: |
if [[ "${{ gitea.ref }}" == "refs/heads/main" ]]; then if [[ "${{ gitea.ref }}" == "refs/heads/main" ]]; then
@@ -45,6 +45,8 @@ jobs:
echo "TAG=dev" >> "$GITHUB_ENV" echo "TAG=dev" >> "$GITHUB_ENV"
fi fi
echo "OWNER_LOWER=$(echo '${{ gitea.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
- name: Ensure docker CLI exists - name: Ensure docker CLI exists
shell: bash shell: bash
run: | run: |
@@ -57,20 +59,21 @@ jobs:
- name: Login to Gitea Registry - name: Login to Gitea Registry
shell: bash shell: bash
run: | run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ secrets.REGISTRY_URL }}" \ set -euo pipefail
printf '%s' "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ secrets.REGISTRY_URL }}" \
-u "${{ secrets.REGISTRY_USER }}" --password-stdin -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build & Push Backend - name: Build & Push Backend
shell: bash shell: bash
run: | run: |
BACKEND_IMAGE="${{ secrets.REGISTRY_URL }}/${{ gitea.repository_owner }}/print-calculator-backend:${{ env.TAG }}" BACKEND_IMAGE="${{ secrets.REGISTRY_URL }}/${{ env.OWNER_LOWER }}/print-calculator-backend:${{ env.TAG }}"
docker build -t "$BACKEND_IMAGE" ./backend docker build -t "$BACKEND_IMAGE" ./backend
docker push "$BACKEND_IMAGE" docker push "$BACKEND_IMAGE"
- name: Build & Push Frontend - name: Build & Push Frontend
shell: bash shell: bash
run: | run: |
FRONTEND_IMAGE="${{ secrets.REGISTRY_URL }}/${{ gitea.repository_owner }}/print-calculator-frontend:${{ env.TAG }}" FRONTEND_IMAGE="${{ secrets.REGISTRY_URL }}/${{ env.OWNER_LOWER }}/print-calculator-frontend:${{ env.TAG }}"
docker build -t "$FRONTEND_IMAGE" ./frontend docker build -t "$FRONTEND_IMAGE" ./frontend
docker push "$FRONTEND_IMAGE" docker push "$FRONTEND_IMAGE"
@@ -78,9 +81,6 @@ jobs:
needs: build-and-push needs: build-and-push
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout (serve per avere compose + env nel workspace)
uses: actions/checkout@v4
- name: Set ENV - name: Set ENV
shell: bash shell: bash
run: | run: |
@@ -92,47 +92,24 @@ jobs:
echo "ENV=dev" >> "$GITHUB_ENV" echo "ENV=dev" >> "$GITHUB_ENV"
fi fi
- name: Create Remote Directory - name: Trigger deploy on Unraid (forced command key)
uses: appleboy/ssh-action@v0.1.10 shell: bash
with: run: |
host: ${{ secrets.SERVER_HOST }} set -euo pipefail
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: mkdir -p /mnt/user/appdata/print-calculator/${{ env.ENV }}/
- name: Copy Compose File to Server # Assicura ssh client
uses: appleboy/scp-action@v0.1.4 apt-get update
with: apt-get install -y --no-install-recommends openssh-client
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "docker-compose.deploy.yml"
target: "/mnt/user/appdata/print-calculator/${{ env.ENV }}/"
- name: Copy Env File to Server mkdir -p ~/.ssh
uses: appleboy/scp-action@v0.1.4 chmod 700 ~/.ssh
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "deploy/envs/${{ env.ENV }}.env"
target: "/mnt/user/appdata/print-calculator/${{ env.ENV }}/"
- name: Execute Remote Deployment # Scrive la chiave privata (multi-line) dal secret
uses: appleboy/ssh-action@v0.1.10 printf '%s' "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' > ~/.ssh/id_ed25519
with: chmod 600 ~/.ssh/id_ed25519
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
set -e
cd /mnt/user/appdata/print-calculator/${{ env.ENV }}/
# il file copiato si chiama "dev.env"/"int.env"/"prod.env" # Aggiunge l'host key (evita prompt interattivi)
mv "${{ env.ENV }}.env" .env ssh-keyscan -H "${{ secrets.SERVER_HOST }}" >> ~/.ssh/known_hosts 2>/dev/null
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ secrets.REGISTRY_URL }}" \ # Invia SOLO "prod/int/dev" come comando (finisce in SSH_ORIGINAL_COMMAND sul server)
-u "${{ secrets.REGISTRY_USER }}" --password-stdin ssh -i ~/.ssh/id_ed25519 -o BatchMode=yes "${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" "${{ env.ENV }}"
docker compose --env-file .env -f docker-compose.deploy.yml pull
docker compose --env-file .env -f docker-compose.deploy.yml up -d --remove-orphans