aboutsummaryrefslogtreecommitdiff
path: root/action.yml
blob: 36778ea21cc8d92f77622c9549d4b3d5610582f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: "Publish org-roam-ui"
description: "Generate org-roam-ui static page and deploy to GitHub Pages"

branding:
  icon: 'zap'
  color: 'gray-dark'

inputs:
  org-roam-db-filename:
    description: "org-roam db filename"
    required: true
  org-roam-directory:
    description: "org-roam directory"
    required: false
    default: "."
  site-title:
    description: "Site title"
    required: false
    default: "ORUI"
  deploy-to-pages:
    description: "Deploy to GitHub Pages"
    required: false
    default: "false"
  ui-ref:
    description: "Specify org-roam-ui branch"
    required: false
    default: "publish-org-roam-ui"

runs:
  using: "composite"
  steps:
    - name: Checkout this repo
      uses: actions/checkout@v4
      with:
        repository: ikoamu/publish-org-roam-ui
        path: action
    - name: Checkout org file repo
      uses: actions/checkout@v4
      with:
        repository: ${{ github.repository }}
        path: orgs
    - name: Checkout org-roam-ui
      uses: actions/checkout@v4
      with:
        repository: ikoamu/org-roam-ui
        ref: ${{ inputs.ui-ref }}
        path: ui

    - name: Setup Node
      uses: actions/setup-node@v4
      with:
        node-version: "20"

    # create graphdata.json and notes
    - name: Install graphdata generator dependencies
      working-directory: action
      run: npm install
      shell: bash
    - name: Generate graphdata.json
      working-directory: action
      run: npm run generate --script_params='../orgs/${{ inputs.org-roam-directory }}/${{ inputs.org-roam-db-filename }}'
      shell: bash
    - name: Create Notes
      working-directory: action
      run: ./create_notes.sh ../orgs/${{ inputs .org-roam-directory }}
      shell: bash
    - name: Create Search data
      working-directory: action
      run: npm run generate:search
      shell: bash
    - name: Copy seachdata.json to ../ui/components/Search
      working-directory: action
      run: cp --force	searchdata.json ../ui/components/Search/
      shell: bash
    - name: Copy org/img to ui/public/
      working-directory: action
      run: |
        if [ -d "../orgs/${{ inputs.org-roam-directory }}/img" ]; then
          cp -r ../orgs/${{ inputs.org-roam-directory }}/img ../ui/public
        fi
      shell: bash

    # build org-roam-ui
    - name: Install org-roam-ui dependencies
      working-directory: ui
      run: yarn install
      shell: bash
    - name: Setting .env
      working-directory: ui
      run: echo "NEXT_PUBLIC_TITLE=${{ inputs.site-title }}" > .env
      shell: bash
    - name: Build org-roam-ui
      working-directory: ui/standalone
      run: ./build-standalone-server.sh ../../action/
      shell: bash
    - name: Add nojekyll
      working-directory: ui
      run: touch ./standalone/out/.nojekyll
      shell: bash

    - name: Upload artifact
      uses: actions/upload-pages-artifact@v3
      with:
        path: "./ui/standalone/out"

    - name: Deploy to GitHub Pages
      if: ${{ inputs.deploy-to-pages == 'true' }}
      id: deployment
      uses: actions/deploy-pages@v4