diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..6cd9a33 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,63 @@ +name: Deploy MathNote to GitHub Pages + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup Node + uses: actions/setup-node@v7 + with: + node-version: 24 + package-manager-cache: false + + - name: Install dependencies + run: npm install --no-audit --no-fund + + - name: Build offline distribution + run: npm run build + + - name: Verify offline distribution + run: node scripts/verify-offline.mjs + + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v4 + with: + path: ./dist + + deploy: + if: github.event_name != 'pull_request' + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Configure GitHub Pages + uses: actions/configure-pages@v5 + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 197f051..9e998c0 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,22 @@ Bu kontrol, build çıktısında uzak script/style/module bağlantısı kalmadı --- +## GitHub Pages + +Repo, GitHub Pages üzerinde kaynak `index.html` dosyasını doğrudan yayınlamak yerine GitHub Actions ile build edilir. `.github/workflows/pages.yml` workflow'u: + +1. npm bağımlılıklarını kurar. +2. `npm run build` ile `dist/` çıktısını üretir. +3. Offline doğrulamasını çalıştırır. +4. `dist/` klasörünü GitHub Pages artifact'i olarak yükler. +5. `main` branch'ine yapılan push/merge sonrasında artifact'i yayınlar. + +GitHub üzerinde bir kez **Settings → Pages → Build and deployment → Source → GitHub Actions** seçilmelidir. Bundan sonra her `main` güncellemesi otomatik olarak `https://alorak.github.io/mathnote/` adresine deploy edilir. + +PR'larda workflow yalnızca build ve doğrulama yapar; canlı deploy yalnızca `main` üzerinde gerçekleşir. + +--- + ## Lisans MIT Lisansı diff --git a/scripts/build.mjs b/scripts/build.mjs index 97724be..e1e0c94 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -40,4 +40,5 @@ if (html.includes('MATHNOTE_BUILD_')) { } await writeFile(new URL('../dist/index.html', import.meta.url), html, 'utf8'); +await writeFile(new URL('../dist/.nojekyll', import.meta.url), '', 'utf8'); console.log('MathNote offline bundle written to dist/.');