Simplify GitHub Pages deployment workflow for basic static site #18
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: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: 'assets/package-lock.json' | |
| - name: Install Node.js dependencies | |
| working-directory: ./assets | |
| run: | | |
| npm ci --prefer-offline --no-audit | |
| npm install esbuild@0.17.11 | |
| - 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 | |
| # Create a minimal index.html | |
| cat > priv/static/index.html << 'EOL' | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Kati Best Design</title> | |
| <link rel="stylesheet" href="/assets/app.css"> | |
| </head> | |
| <body> | |
| <h1>Kati Best Design</h1> | |
| <p>Coming soon...</p> | |
| </body> | |
| </html> | |
| EOL | |
| # Ensure CNAME is present | |
| echo "katibestdesign.com" > priv/static/CNAME | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./priv/static | |
| force_orphan: true |