diff --git a/.github/workflows/azure-static-web-apps-ambitious-smoke-0fd019710.yml b/.github/workflows/azure-static-web-apps-ambitious-smoke-0fd019710.yml new file mode 100644 index 0000000..e5fd5fc --- /dev/null +++ b/.github/workflows/azure-static-web-apps-ambitious-smoke-0fd019710.yml @@ -0,0 +1,46 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_SMOKE_0FD019710 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "./src" # App source code path + api_location: "./api" # Api source code path - optional + output_location: "." # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_SMOKE_0FD019710 }} + action: "close" diff --git a/.github/workflows/azure-static-web-apps-blue-water-088c66f10.yml b/.github/workflows/azure-static-web-apps-blue-water-088c66f10.yml new file mode 100644 index 0000000..78586bf --- /dev/null +++ b/.github/workflows/azure-static-web-apps-blue-water-088c66f10.yml @@ -0,0 +1,46 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BLUE_WATER_088C66F10 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "./src" # App source code path + api_location: "./api" # Api source code path - optional + output_location: "." # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BLUE_WATER_088C66F10 }} + action: "close" diff --git a/src/index.html b/src/index.html index 6cbfc9a..09e08b2 100644 --- a/src/index.html +++ b/src/index.html @@ -4,12 +4,12 @@ - Vanilla JavaScript App + Vanilla Static web App
-

Vanilla JavaScript App

+

Vanilla Static web App

Loading content from the API:

diff --git a/src/staticwebapp.config.json b/src/staticwebapp.config.json new file mode 100644 index 0000000..029de9e --- /dev/null +++ b/src/staticwebapp.config.json @@ -0,0 +1,17 @@ +{ + "navigationFallback": { + "rewrite": "/index.html" + }, + "routes": [ + { + "route": "/*", + "allowedRoles": [ "authenticated" ] + } + ], + "responseOverrides": { + "401": { + "statusCode": 302, + "redirect": "/.auth/login/aad" + } + } +} diff --git a/swa-db-connections/staticwebapp.database.config.json b/swa-db-connections/staticwebapp.database.config.json new file mode 100644 index 0000000..bb7811b --- /dev/null +++ b/swa-db-connections/staticwebapp.database.config.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://dataapibuilder.azureedge.net/schemas/latest/dab.draft.schema.json", + "data-source": { + "database-type": "mssql", + "options": { + "set-session-context": false + }, + "connection-string": "@env('DATABASE_CONNECTION_STRING')" + }, + "runtime": { + "rest": { + "enabled": true, + "path": "/rest" + }, + "graphql": { + "allow-introspection": true, + "enabled": true, + "path": "/graphql" + }, + "host": { + "mode": "production", + "cors": { + "origins": ["http://localhost:4280"], + "allow-credentials": false + }, + "authentication": { + "provider": "StaticWebApps" + } + } + }, + "entities": { + "Person": { + "source": "dbo.MyTestPersonTable", + "permissions": [ + { + "actions": ["*"], + "role": "anonymous" + } + ] + } + } +} diff --git a/tests/Test.README.md b/tests/Test.README.md deleted file mode 100644 index 65f1284..0000000 --- a/tests/Test.README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Testing - -To run playwright tests run `npm run playwright_test`. In order to run the playwright tests the start script `swa start src --api-location api` was added. \ No newline at end of file diff --git a/tests/playwright.spec.ts b/tests/playwright.spec.ts deleted file mode 100644 index 1cb7a8d..0000000 --- a/tests/playwright.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('basic test', async ({ page }) => { - await page.goto('/'); - await page.waitForSelector('h1') - await expect(page.locator('h1')).toContainText('Vanilla JavaScript App'); - await expect(page.locator('b')).toContainText('Hello from the API') -}) \ No newline at end of file