kat-tax / vslite

More than Monaco, less than VSCode
https://vslite.dev
MIT License
61 stars 7 forks source link

Create pages.yml #15

Closed FossPrime closed 1 year ago

FossPrime commented 1 year ago

Useful as a bare minimum check on PR's at the moment. And also the fast sanity check when reading build instructions...

FossPrime commented 1 year ago

DERP... this isn't possible because of the COOP requirement.

Basically your server needs to have the require corp header... which github does not have.

FossPrime commented 1 year ago

Turns out you can use Github pages for hosting... but you'll have to use Cloudflare DNS's Transform Rules to attach the headers.

... We could have a redirect that does this for everyone...

FossPrime commented 1 year ago

How to setup with github pages + cloudflare DNS:

  1. build it using the build script on this PR
  2. Enable Pages with Github actions in your repo settings, it's enabled as soon as you open the page
  3. On cloudflare DNS enable full SSL/TLS mode, not doing so will cause a redirect loop
  4. Configure a custom domain, point a CNAME to USERNAME.github.io
  5. Run the action. Go to Actions -> Deploy to Pages -> Run Workflow
  6. Under Rules -> Transform Rules -> Modify Response Header add a New rule with Hostname equals your custom domain and Then... add Cross-Origin-Embedder-Policy = require-corp and Cross-Origin-Opener-Policy = same-origin
# Simple workflow for deploying static content to GitHub Pages
name: Deploy to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ['master']

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: 'pages'
  cancel-in-progress: true

env:
  VITE_BASE: ${{github.event.repository.name}}/

jobs:
  # Single deploy job since we're just deploying
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2
        with:
          version: latest
      - run: pnpm i --fix-lockfile # Fix version differences
      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: lts/*
          cache: 'pnpm'
      - name: Install dependencies
        run: npm i -g @antfu/ni && ni
      - name: Build
        run: npx vite build
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          # Upload dist repository
          path: './dist'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
FossPrime commented 1 year ago

I can't relink this PR so redoing in new PR. It needed to be a master PR because... Pages.