Dendron publish

V1

# This is a basic workflow to help you get started with Actions

name: Dendron Publish

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Checkout source
        uses: actions/checkout@v2

      - name: Install npm dependencies
        run: npm install
        
      - name: Build pod
        run: npm run dendron-cli -- buildSiteV2 --wsRoot .  --stage prod
        
      - name: Pushes to another repository
        uses: cpina/github-action-push-to-another-repository@main
        env:
          API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
        with:
          source-directory: 'docs'
          destination-github-username: 'joyearnaud'
          destination-repository-name: 'knowledge-published'
          user-email: joye.arnaud@gmail.com
          target-branch: main

V2

name: Dendron

on:
  push:
    branches:
    - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout source
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    # Retain Node modules across builds
    - name: Restore Node modules cache
      uses: actions/cache@v2
      id: node-modules-cache
      with:
        path: |
          node_modules
          .next
        key: node-modules-${{ hashFiles('yarn.lock')}}

    - name: Install npm dependencies
      run: yarn

    - name: Initialize or pull Next.js template
      run: "(test -d .next) && (echo 'updating Dendron next...' && cd .next && git reset --hard && git clean -f && git pull) || (echo 'init Dendron next' && npx dendron publish init)"

    - name: Install dependencies
      run: cd .next && yarn && cd ..

    - name: Export notes
      run: npx dendron publish build

    - name: Prep notes for publish
      run: cd .next && yarn export && cd ..

    - name: Remove docs if exist
      run: '(test -d docs && rm -rf docs) || echo skipping'

    - name: Update Notes
      run: |
        cd .next && mv out ../docs && touch ../docs/.nojekyll && cd ..

    - name: Deploy site
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_branch: pages
        publish_dir: docs/
        force_orphan: true

Backlinks