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.
This commit is contained in:
@@ -8,8 +8,6 @@ env:
|
|||||||
AWS_REGION: eu-central-1
|
AWS_REGION: eu-central-1
|
||||||
S3_BUCKET: filamenteka-frontend
|
S3_BUCKET: filamenteka-frontend
|
||||||
INSTANCE_ID: i-03956ecf32292d7d9
|
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_API_URL: https://api.filamenteka.rs/api
|
||||||
NEXT_PUBLIC_MATOMO_URL: https://analytics.demirix.dev
|
NEXT_PUBLIC_MATOMO_URL: https://analytics.demirix.dev
|
||||||
NEXT_PUBLIC_MATOMO_SITE_ID: "7"
|
NEXT_PUBLIC_MATOMO_SITE_ID: "7"
|
||||||
@@ -152,14 +150,15 @@ jobs:
|
|||||||
--document-name "AWS-RunShellScript" \
|
--document-name "AWS-RunShellScript" \
|
||||||
--parameters 'commands=[
|
--parameters 'commands=[
|
||||||
"set -e",
|
"set -e",
|
||||||
"mkdir -p '"$API_DIR"'/database/migrations",
|
"cd /tmp",
|
||||||
"cd '"$API_DIR"'",
|
"curl -sf -o repo.tar.gz https://git.demirix.dev/dax/Filamenteka/archive/main.tar.gz",
|
||||||
"curl -sf -o database/schema.sql '"$GITEA_RAW"'/database/schema.sql",
|
"tar xzf repo.tar.gz",
|
||||||
"curl -sf -o api/migrate.js '"$GITEA_RAW"'/api/migrate.js",
|
"cp -r filamenteka/database /home/ubuntu/filamenteka-api/database",
|
||||||
"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",
|
"cp filamenteka/api/migrate.js /home/ubuntu/filamenteka-api/api/migrate.js",
|
||||||
"echo Migration files downloaded:",
|
"rm -rf repo.tar.gz filamenteka",
|
||||||
"ls -la database/migrations/",
|
"echo Migration files:",
|
||||||
"cd api && node migrate.js"
|
"ls -la /home/ubuntu/filamenteka-api/database/migrations/",
|
||||||
|
"cd /home/ubuntu/filamenteka-api/api && node migrate.js"
|
||||||
]' \
|
]' \
|
||||||
--output json \
|
--output json \
|
||||||
--query "Command.CommandId" --output text)
|
--query "Command.CommandId" --output text)
|
||||||
@@ -207,9 +206,9 @@ jobs:
|
|||||||
--document-name "AWS-RunShellScript" \
|
--document-name "AWS-RunShellScript" \
|
||||||
--parameters 'commands=[
|
--parameters 'commands=[
|
||||||
"set -e",
|
"set -e",
|
||||||
"cd '"$API_DIR"'",
|
"cd /home/ubuntu/filamenteka-api",
|
||||||
"cp server.js server.js.backup",
|
"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",
|
"sudo systemctl restart node-api",
|
||||||
"echo API deployed and restarted"
|
"echo API deployed and restarted"
|
||||||
]' \
|
]' \
|
||||||
@@ -272,7 +271,7 @@ jobs:
|
|||||||
--instance-ids "$INSTANCE_ID" \
|
--instance-ids "$INSTANCE_ID" \
|
||||||
--document-name "AWS-RunShellScript" \
|
--document-name "AWS-RunShellScript" \
|
||||||
--parameters 'commands=[
|
--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"
|
"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
|
--output json
|
||||||
@@ -288,6 +287,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
token: ${{ github.token }}
|
||||||
|
|
||||||
- name: Create deploy tag
|
- name: Create deploy tag
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user