-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Host site on Azure Static Web Apps; load lessons from local files #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Deploy to Azure Static Web Apps | ||
|
|
||
| # Hosts the site on Azure Static Web Apps with the REPO ROOT as the web root, | ||
| # so /site/* serves the app and /phases/* serves lesson content (docs/en.md, | ||
| # quiz.json) that lesson.html loads at runtime via relative paths — no GitHub | ||
| # fetch needed. Requires the repo secret AZURE_STATIC_WEB_APPS_API_TOKEN | ||
| # (the deployment token from the Azure Static Web App resource). | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build_and_deploy: | ||
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | ||
| runs-on: ubuntu-latest | ||
| name: Build and Deploy | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: false | ||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set The checkout action leaves Since this workflow does not perform any git operations after checkout, the credentials are unnecessary. 🔒 Proposed fix - uses: actions/checkout@v4
with:
+ persist-credentials: false
submodules: false🧰 Tools🪛 zizmor (1.25.2)[warning] 26-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [error] 26-26: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Generate site/data.js | ||
| run: node site/build.js | ||
|
|
||
| - name: Deploy | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
| action: upload | ||
| # Repo root is the web root so /phases/* is served alongside /site/*. | ||
| app_location: "/" | ||
| output_location: "" | ||
| skip_app_build: true | ||
|
|
||
| close_pull_request: | ||
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
| runs-on: ubuntu-latest | ||
| name: Close PR preview | ||
| steps: | ||
| - name: Close | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| action: close | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "routes": [ | ||
| { "route": "/", "rewrite": "/site/index.html" }, | ||
| { "route": "/glossary", "rewrite": "/site/glossary.html" }, | ||
| { "route": "/catalog", "rewrite": "/site/catalog.html" }, | ||
| { "route": "/path", "rewrite": "/site/prereqs.html" }, | ||
| { "route": "/roadmap", "rewrite": "/site/prereqs.html" }, | ||
| { "route": "/about", "rewrite": "/site/about.html" } | ||
| ], | ||
| "navigationFallback": { | ||
| "rewrite": "/site/index.html", | ||
| "exclude": ["/site/*", "/phases/*", "/assets/*", "/*.{js,css,png,jpg,jpeg,svg,webp,woff2,woff,ttf,ico,md,json}"] | ||
| }, | ||
| "globalHeaders": { | ||
| "X-Content-Type-Options": "nosniff" | ||
| }, | ||
| "mimeTypes": { | ||
| ".md": "text/markdown", | ||
| ".json": "application/json" | ||
| }, | ||
| "responseOverrides": { | ||
| "404": { "rewrite": "/site/index.html" } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: rohitg00/ai-engineering-from-scratch
Length of output: 280
🏁 Script executed:
Repository: rohitg00/ai-engineering-from-scratch
Length of output: 123
🏁 Script executed:
Repository: rohitg00/ai-engineering-from-scratch
Length of output: 2269
Pin GitHub Actions in .github/workflows/azure-static-web-apps.yml to immutable commit SHAs.
Mutable tags like
@v4/@v1can change the workflow code without modifying the workflow file. Replace the followinguses:entries (keep the existingwith:blocks unchanged):actions/checkout@v4→actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4actions/setup-node@v4→actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4Azure/static-web-apps-deploy@v1→Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9 # v1Azure/static-web-apps-deploy@v1→Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9 # v1🧰 Tools
🪛 zizmor (1.25.2)
[warning] 26-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 26-26: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents
Source: Linters/SAST tools