From 746f0925d0a24a0162bdff0514cdc825baafeab2 Mon Sep 17 00:00:00 2001 From: DaX Date: Thu, 5 Mar 2026 01:33:19 +0100 Subject: [PATCH] Fix CI/CD pipeline: use archive download for migrations, inline SSM paths Replace complex Gitea API + python parsing in SSM with simple repo archive download and extraction. Inline hardcoded paths in SSM commands instead of shell variable expansion through single quotes to avoid quoting issues. --- .gitea/workflows/deploy.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 8ce607e..7105d6c 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -8,8 +8,6 @@ env: AWS_REGION: eu-central-1 S3_BUCKET: filamenteka-frontend INSTANCE_ID: i-03956ecf32292d7d9 - API_DIR: /home/ubuntu/filamenteka-api - GITEA_RAW: https://git.demirix.dev/dax/Filamenteka/raw/branch/main NEXT_PUBLIC_API_URL: https://api.filamenteka.rs/api NEXT_PUBLIC_MATOMO_URL: https://analytics.demirix.dev NEXT_PUBLIC_MATOMO_SITE_ID: "7" @@ -152,14 +150,15 @@ jobs: --document-name "AWS-RunShellScript" \ --parameters 'commands=[ "set -e", - "mkdir -p '"$API_DIR"'/database/migrations", - "cd '"$API_DIR"'", - "curl -sf -o database/schema.sql '"$GITEA_RAW"'/database/schema.sql", - "curl -sf -o api/migrate.js '"$GITEA_RAW"'/api/migrate.js", - "for f in $(curl -sf '"https://git.demirix.dev/api/v1/repos/dax/Filamenteka/contents/database/migrations"' | python3 -c \"import sys,json; [print(x[\\\"name\\\"]) for x in json.load(sys.stdin) if x[\\\"name\\\"].endswith(\\\".sql\\\")]\"); do curl -sf -o database/migrations/$f '"$GITEA_RAW"'/database/migrations/$f; done", - "echo Migration files downloaded:", - "ls -la database/migrations/", - "cd api && node migrate.js" + "cd /tmp", + "curl -sf -o repo.tar.gz https://git.demirix.dev/dax/Filamenteka/archive/main.tar.gz", + "tar xzf repo.tar.gz", + "cp -r filamenteka/database /home/ubuntu/filamenteka-api/database", + "cp filamenteka/api/migrate.js /home/ubuntu/filamenteka-api/api/migrate.js", + "rm -rf repo.tar.gz filamenteka", + "echo Migration files:", + "ls -la /home/ubuntu/filamenteka-api/database/migrations/", + "cd /home/ubuntu/filamenteka-api/api && node migrate.js" ]' \ --output json \ --query "Command.CommandId" --output text) @@ -207,9 +206,9 @@ jobs: --document-name "AWS-RunShellScript" \ --parameters 'commands=[ "set -e", - "cd '"$API_DIR"'", + "cd /home/ubuntu/filamenteka-api", "cp server.js server.js.backup", - "curl -sf -o server.js '"$GITEA_RAW"'/api/server.js", + "curl -sf -o server.js https://git.demirix.dev/dax/Filamenteka/raw/branch/main/api/server.js", "sudo systemctl restart node-api", "echo API deployed and restarted" ]' \ @@ -272,7 +271,7 @@ jobs: --instance-ids "$INSTANCE_ID" \ --document-name "AWS-RunShellScript" \ --parameters 'commands=[ - "cd '"$API_DIR"'", + "cd /home/ubuntu/filamenteka-api", "if [ -f server.js.backup ]; then cp server.js.backup server.js && sudo systemctl restart node-api && echo Rollback complete; else echo No backup found; fi" ]' \ --output json @@ -288,6 +287,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + token: ${{ github.token }} - name: Create deploy tag run: |