Skip to content

Add Nix config files #67

Add Nix config files

Add Nix config files #67

Workflow file for this run

name: Build and deploy docs
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
# =====================================================
# Build
# =====================================================
- name: Check out submodules
run: |
nix develop -c \
make submodules
- name: Build site
run: |
nix develop -c \
make all
# =====================================================
# Deploy docs to Netlify
# =====================================================
- name: Configure pull release name
if: ${{github.event_name == 'pull_request'}}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
- name: Configure branch release name
if: ${{github.event_name != 'pull_request'}}
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
- name: Create Github "view deployment" button in PR
if: ${{github.event_name == 'pull_request'}}
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref }}
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Deploy to Netlify
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
REF_NAME: ${{ github.ref_name }}
ALIAS: ${{ steps.deployment.outputs.env }}
run: |
npm install -g [email protected]
# push main branch to production, others to preview --
if [ "${REF_NAME}" == "main" ]; then
netlify deploy --dir=_build/ --prod
else
netlify deploy --dir=_build/ --alias="${ALIAS}"
fi
- name: Update Github "view deployment" button in PR
uses: bobheadxi/deployments@v1
if: ${{ steps.deployment.conclusion != 'failure' && github.event_name == 'pull_request'}}
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ steps.deployment.outputs.env }}
env_url: "https://${{ steps.deployment.outputs.env }}--pyshiny.netlify.app"
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"