softinio.com/.github/workflows/deploy.yml
Salar Rahmanian 1fd2958cdf fix: correct generate_feeds config and add caching to GitHub Actions
- Fix typo in config.toml: generate_feed -> generate_feeds
- Add Nix store caching to speed up CI builds
- Add flake inputs caching for faster dependency resolution
2025-06-13 20:06:50 -07:00

68 lines
2.1 KiB
YAML

name: Build and Deploy
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: Setup Nix store cache
uses: actions/cache@v4
with:
path: /nix/store
key: ${{ runner.os }}-nix-store-${{ hashFiles('**/flake.lock') }}
restore-keys: |
${{ runner.os }}-nix-store-
- name: Cache flake inputs
uses: actions/cache@v4
with:
path: ~/.cache/nix
key: ${{ runner.os }}-nix-flake-${{ hashFiles('**/flake.lock') }}
restore-keys: |
${{ runner.os }}-nix-flake-
- name: Build site (pull request)
if: github.event_name == 'pull_request'
run: |
# Update base URL for PR preview
sed -i "s|base_url = \"https://www.softinio.com\"|base_url = \"https://${{ github.head_ref }}.softinio.com\"|" ./config.toml
nix build
nix flake show
ls result
- name: Deploy to Cloudflare Pages (pull request)
if: github.event_name == 'pull_request'
run: |
nix develop --command wrangler pages deploy result --branch=${{ github.head_ref }} --project-name=softinio --commit-dirty=true
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Build site (main branch)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
nix build
- name: Deploy to Cloudflare Pages (main branch)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
nix develop --command wrangler pages deploy result --project-name=softinio --commit-dirty=true
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}