Update static file handling for GitHub Pages #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: '1.15.7' | |
| otp-version: '26.2.1' | |
| - name: Restore dependencies | |
| run: | | |
| mix local.hex --force | |
| mix local.rebar --force | |
| mix deps.get | |
| - name: Install Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build assets | |
| run: | | |
| # Create necessary directories | |
| mkdir -p priv/static/images | |
| mkdir -p priv/static/assets | |
| # Copy static assets | |
| cp -r priv/static/images/* priv/static/images/ 2>/dev/null || true | |
| cp -r assets/static/* priv/static/ 2>/dev/null || true | |
| # Build and digest assets | |
| mix assets.deploy | |
| mix phx.digest | |
| # Ensure CNAME is present | |
| echo "katibestdesign.com" > priv/static/CNAME | |
| # Create a 404.html for GitHub Pages | |
| echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Page Not Found</title></head><body><h1>404 - Page Not Found</h1><p>The page you are looking for does not exist.</p></body></html>' > priv/static/404.html | |
| # Create a _redirects file for Netlify-style redirects | |
| echo "/images/* /images/:splat 200" > priv/static/_redirects | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./priv/static | |
| force_orphan: true |