Fix CI/CD pipeline: use archive download for migrations, inline SSM paths
All checks were successful
Deploy / tag-deploy (push) Successful in 4s
Deploy / detect (push) Successful in 4s
Deploy / deploy-api (push) Has been skipped
Deploy / deploy-frontend (push) Successful in 2m5s

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.
This commit is contained in:
DaX
2026-03-05 01:33:19 +01:00
parent 2985ea4457
commit 746f0925d0

View File

@@ -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: |