mirror of
https://github.com/softinio/softinio.com.git
synced 2025-09-03 10:36:42 -07:00
55 lines
1.8 KiB
YAML
55 lines
1.8 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: DeterminateSystems/determinate-nix-action@v3
|
|
|
|
- name: Setup FlakeHub Cache
|
|
uses: DeterminateSystems/flakehub-cache-action@main
|
|
|
|
- name: Check Nix flake
|
|
uses: DeterminateSystems/nix-flake-checker-action@main
|
|
|
|
- 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.pages.dev\"|" ./config.toml
|
|
nix build
|
|
nix flake show
|
|
ls result
|
|
echo "Preview URL: https://${{ github.head_ref }}.softinio.pages.dev"
|
|
|
|
- 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 }}
|