diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 1f53006..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Deploy to Azure (on merge to main) - -on: - push: - branches: [main] - -env: - DOTNET_VERSION: "9.0.x" - -jobs: - build-and-deploy: - name: Build, Publish and Deploy - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: Restore - run: dotnet restore Aquiis.sln - - - name: Publish - run: dotnet publish ./Aquiis.SimpleStart/Aquiis.SimpleStart.csproj -c Release -o ${{ github.workspace }}/publish - - - name: Azure Login (for deployment) - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Show publish output - run: | - echo "Publish folder contents:" - ls -la "${{ github.workspace }}/publish" || true - du -sh "${{ github.workspace }}/publish" || true - - - name: Zip publish output - run: | - cd "${{ github.workspace }}" - if [ -d ./publish ]; then - rm -f publish.zip - zip -r publish.zip publish - else - echo "ERROR: publish folder not found" && exit 3 - fi - - - name: Deploy with Azure CLI - run: | - az webapp deploy \ - --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \ - --name ${{ secrets.AZURE_WEBAPP_NAME }} \ - --src-path "${{ github.workspace }}/publish.zip" \ - --type zip - - - name: Extract DB settings and export to GITHUB_ENV - run: | - DB_FILE=$(jq -r '.ApplicationSettings.DatabaseFileName // "app_v0.0.0.db"' Aquiis.SimpleStart/appsettings.json) - PREV_DB_FILE=$(jq -r '.ApplicationSettings.PreviousDatabaseFileName // ""' Aquiis.SimpleStart/appsettings.json) - APP_VERSION=$(jq -r '.ApplicationSettings.Version // ""' Aquiis.SimpleStart/appsettings.json) - SCHEMA_VERSION=$(jq -r '.ApplicationSettings.SchemaVersion // ""' Aquiis.SimpleStart/appsettings.json) - echo "DB_FILE=$DB_FILE" >> "$GITHUB_ENV" - echo "PREV_DB_FILE=$PREV_DB_FILE" >> "$GITHUB_ENV" - echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV" - echo "SCHEMA_VERSION=$SCHEMA_VERSION" >> "$GITHUB_ENV" - echo "DB_PATH=/home/data/$DB_FILE" >> "$GITHUB_ENV" - shell: bash - - name: Backup existing DB (if any) - if: env.DB_PATH != '' - run: | - echo "Skipping Kudu-based DB backup because publish-profile/Kudu is not used when deploy via service principal." - echo "Ensure app startup handles DB migrations/backups or run an alternative remote command if necessary." - - - name: Azure Login (for App Settings) - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Configure App Settings (set SQLite connection string and app metadata) - run: | - az webapp config appsettings set \ - --resource-group "${{ secrets.AZURE_RESOURCE_GROUP }}" \ - --name "${{ secrets.AZURE_WEBAPP_NAME }}" \ - --settings \ - "ConnectionStrings__DefaultConnection=DataSource=/home/data/$DB_FILE;Cache=Shared" \ - "ApplicationSettings__Version=$APP_VERSION" \ - "ApplicationSettings__DatabaseFileName=$DB_FILE" \ - "ApplicationSettings__PreviousDatabaseFileName=$PREV_DB_FILE" \ - "ApplicationSettings__SchemaVersion=$SCHEMA_VERSION" \ - ASPNETCORE_ENVIRONMENT=Production - shell: bash diff --git a/Aquiis.SimpleStart/.gitattributes b/Aquiis.SimpleStart/.gitattributes index c12b159..22412d8 100644 --- a/Aquiis.SimpleStart/.gitattributes +++ b/Aquiis.SimpleStart/.gitattributes @@ -1,3 +1,3 @@ *.cs* linguist-language=C# *.razor linguist-language=Razor -*.sql linguist-language=SQL \ No newline at end of file +*.sql linguist-language=SQL-92 \ No newline at end of file diff --git a/scripts/kudu-backup-db.sh b/scripts/kudu-backup-db.sh deleted file mode 100644 index 8ba2f14..0000000 --- a/scripts/kudu-backup-db.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# Usage: ./kudu-backup-db.sh /path/to/publish_profile.xml APP_NAME [/home/data/app.db] -PUBLISH_PROFILE_FILE=${1:-} -APP_NAME=${2:-} -SRC_DB_PATH=${3:-/home/data/app_v0.0.0.db} -if [ -z "$PUBLISH_PROFILE_FILE" ] || [ -z "$APP_NAME" ]; then - echo "Usage: $0 [src-db-path]" >&2 - exit 2 -fi - -KUDU_USER=$(grep -o 'userName="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userName="([^"]+)"/\1/') -KUDU_PWD=$(grep -o 'userPWD="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userPWD="([^"]+)"/\1/') - - -TS=$(date +%Y%m%d%H%M%S) -BACKUP_PATH="/home/data/Backups/$(basename $SRC_DB_PATH).$TS" - -API="https://${APP_NAME}.scm.azurewebsites.net/api/command" -CMD="mkdir -p /home/data/Backups && cp '$SRC_DB_PATH' '$BACKUP_PATH' && ls -l /home/data/Backups" - -echo "Backing up $SRC_DB_PATH -> $BACKUP_PATH on ${APP_NAME} via Kudu..." -curl -s -X POST -u "$KUDU_USER:$KUDU_PWD" -H "Content-Type: application/json" -d "{\"command\":\"$CMD\"}" "$API" | jq . - -echo "Backup complete: $BACKUP_PATH" diff --git a/scripts/kudu-cleanup-backups.sh b/scripts/kudu-cleanup-backups.sh deleted file mode 100644 index b541b20..0000000 --- a/scripts/kudu-cleanup-backups.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# Usage: ./kudu-cleanup-backups.sh /path/to/publish_profile.xml APP_NAME RETAIN_DAYS -PUBLISH_PROFILE_FILE=${1:-} -APP_NAME=${2:-} -RETAIN_DAYS=${3:-30} -if [ -z "$PUBLISH_PROFILE_FILE" ] || [ -z "$APP_NAME" ]; then - echo "Usage: $0 [retain-days]" >&2 - exit 2 -fi - -KUDU_USER=$(grep -o 'userName="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userName="([^"]+)"/\1/') -KUDU_PWD=$(grep -o 'userPWD="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userPWD="([^"]+)"/\1/') - - -API="https://${APP_NAME}.scm.azurewebsites.net/api/command" -CMD="find /home/data/Backups -type f -mtime +$RETAIN_DAYS -print -delete || true && ls -l /home/data/Backups" - -echo "Cleaning up backups older than $RETAIN_DAYS days on ${APP_NAME} via Kudu..." -curl -s -X POST -u "$KUDU_USER:$KUDU_PWD" -H "Content-Type: application/json" -d "{\"command\":\"$CMD\"}" "$API" | jq . - -echo "Cleanup complete." diff --git a/scripts/kudu-create-data-dir.sh b/scripts/kudu-create-data-dir.sh deleted file mode 100644 index 4f1f4b4..0000000 --- a/scripts/kudu-create-data-dir.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# Usage: ./kudu-create-data-dir.sh /path/to/publish_profile.xml APP_NAME -PUBLISH_PROFILE_FILE=${1:-} -APP_NAME=${2:-} -if [ -z "$PUBLISH_PROFILE_FILE" ] || [ -z "$APP_NAME" ]; then - echo "Usage: $0 " >&2 - exit 2 -fi - -KUDU_USER=$(grep -o 'userName="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userName="([^"]+)"/\1/') -KUDU_PWD=$(grep -o 'userPWD="[^"]*"' "$PUBLISH_PROFILE_FILE" | head -1 | sed -E 's/userPWD="([^"]+)"/\1/') - -API="https://${APP_NAME}.scm.azurewebsites.net/api/command" -CMD='mkdir -p /home/data && chmod 775 /home/data' - -echo "Creating /home/data on ${APP_NAME} via Kudu..." -curl -s -X POST -u "$KUDU_USER:$KUDU_PWD" -H "Content-Type: application/json" -d "{\"command\":\"$CMD\"}" "$API" | jq . - -echo "Done."