Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/check-code-nodes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check Code nodes point at src/

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check
run: node scripts/code-nodes.js check

# Builds what publishing would send to n8n from this pull request and from its base
# branch, and writes the difference to the run's summary page for reviewers.
preview:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Compare with the base branch
run: |
set -euo pipefail
node scripts/code-nodes.js build
git worktree add "$RUNNER_TEMP/base" "$BASE_SHA"
if [ -f "$RUNNER_TEMP/base/scripts/code-nodes.js" ]; then
node "$RUNNER_TEMP/base/scripts/code-nodes.js" build
else
cp -r "$RUNNER_TEMP/base/nodes" "$RUNNER_TEMP/base/dist"
fi
node scripts/code-nodes.js compare "$RUNNER_TEMP/base/dist" dist | tee -a "$GITHUB_STEP_SUMMARY"
4 changes: 3 additions & 1 deletion .github/workflows/publish-n8n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main]
paths:
- "nodes/**/*.json"
- "src/**/*.js"
workflow_dispatch:
inputs:
file:
Expand Down Expand Up @@ -37,7 +38,8 @@ jobs:
set -euo pipefail
git config core.quotepath off
if [ "${{ github.event_name }}" == "push" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
git diff -z --name-only --diff-filter=AM "$BEFORE_SHA" "$AFTER_SHA" -- 'nodes/*.json' > "$RUNNER_TEMP/files.list"
git diff -z --name-only --diff-filter=AM "$BEFORE_SHA" "$AFTER_SHA" -- 'nodes/*.json' 'src/*.js' \
| node scripts/code-nodes.js affected > "$RUNNER_TEMP/files.list"
elif [ -n "$INPUT_FILE" ]; then
printf '%s\0' "$INPUT_FILE" > "$RUNNER_TEMP/files.list"
else
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Thumbs.db
# Docker volumes and data
n8n_data/

# Workflows built with their Code-node code filled in (make build)
dist/

# Temporary files
*.tmp
*.log
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
.PHONY: validate-json
validate-json:
find nodes -name '*.json' -exec python3 -c 'import json,sys; f=sys.argv[1]; json.load(open(f)); print("Valid:", f)' {} \;

# Write every workflow, with its Code-node code filled in from src/, to dist/
.PHONY: build
build:
node scripts/code-nodes.js build

# Fail unless every Code node points at a source file in src/ and every source file is used
.PHONY: check
check:
node scripts/code-nodes.js check

# Move real code found in the workflow JSON into src/, leaving placeholders
.PHONY: extract
extract:
node scripts/code-nodes.js extract
27 changes: 23 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,39 @@

## Publishing workflows to n8n Cloud

Merging a change to a workflow JSON under `nodes/` into `main` publishes it to <https://innersourcecommons.app.n8n.cloud/> automatically, through the `Publish workflows to n8n Cloud` GitHub Action.
The Action publishes only the workflow files that changed in the push.
Each file is matched to its workflow by the `id` field in the JSON.
Merging a change to a workflow JSON under `nodes/`, or to one of its Code nodes' files under `src/`, into `main` publishes that workflow to <https://innersourcecommons.app.n8n.cloud/> automatically, through the `Publish workflows to n8n Cloud` GitHub Action.
The Action publishes only the workflows that changed in the push.
Each workflow JSON is matched to its n8n workflow by its `id` field.
Publishing replaces the workflow's name, nodes, connections, settings, and static data, and leaves its active or inactive state as it is.

The Action reads the API key from the `N8N_API_KEY` repository secret.

## Editing a Code node's JavaScript

Each Code node's JavaScript lives only in its own file under `src/`, so a pull request shows a code change as ordinary lines of JavaScript.
In the workflow JSON, the node's code is the one-line comment `// Code comes from src/<path>.js at build time.`, naming that file.
Publishing fills in the real code from the file, through `scripts/update-workflow.sh`, which the GitHub Action and a manual publish both run.
The code runs as the body of an n8n Code node, so a top-level `return` and n8n's built-in globals are valid there even where an editor marks them as errors.

To change a Code node, edit its file under `src/` and commit it.

`make build` writes every workflow with its code filled in to `dist/`, ready to import into an n8n instance by hand.
The `Check Code nodes point at src/` GitHub Action fails a pull request in which a Code node holds code instead of naming a file, names a file that doesn't exist, or a file under `src/` belongs to no Code node; run `make check` to see the same result locally.
On a pull request, the same Action's `preview` job builds what publishing would send to n8n from the pull request and from its base branch, and lists each workflow as identical or names what changed, on the run's summary page.

When a workflow comes from an export of the n8n editor, its Code nodes hold their real code.
Copy the export over the workflow's file under `nodes/` and run `make extract`, which moves each node's code into `src/` and puts the one-line comment back in the JSON.
A new Code node's file is `src/<subfolder under nodes/>/<workflow file name>/<node name>.js`, with each name lowercased and every run of characters other than letters and digits turned into a hyphen.
Extract also removes files under `src/` whose Code node is gone, and stops with an error if publishing would not reproduce the exported code exactly.

## Credential errors (e.g. “does not exist for type …”)

n8n stores credentials by **ID** on the server. If you see `Credential with ID "…" does not exist for type "googleDriveOAuth2Api"` on a node such as **Get All Folders**:

1. Open the workflow in the editor, select that node, and under **Credential** choose an existing **Google Drive OAuth2 API** credential (or create one and connect it).
2. Save the workflow.

Workflow JSON in this repo omits credential IDs where possible so a fresh import asks you to map credentials by name instead of reusing another instance’s IDs. If your copy still has a bad ID, fix it in the UI as above, or re-import the workflow from `nodes/working-group-roles/ISC - GDrive.json` and attach your Drive credential when prompted.
Workflow JSON in this repo omits credential IDs where possible so a fresh import asks you to map credentials by name instead of reusing another instance’s IDs.
If your copy still has a bad ID, fix it in the UI as above, or run `make build` and re-import the workflow from `dist/governance/ISC - GDrive.json` and attach your Drive credential when prompted.

**Google Drive + HTTP Request:** Some Google OAuth credentials are configured to **disallow** use inside the **HTTP Request** node (n8n blocks this for security). Workflows such as **ISC - GDrive** use the **Google Drive** node instead so the same APIs run without that restriction.
2 changes: 1 addition & 1 deletion nodes/New Member Introduction.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
},
{
"parameters": {
"jsCode": "// Edit the blocks array below to match Slack Block Kit. Copy the whole blocks array\n// and paste into https://app.slack.com/block-kit-builder/ to preview.\n// block_kit_builder_url in the output opens the builder with this payload.\nconst displayName = $input.first().json.new_user_display_name || 'there';\nconst blocks = [\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: `*Hey ${displayName}!*\\n\\nWelcome to the InnerSource Commons! It's so cool you're here! 🎉\\n\\nThis is a global community of practitioners, researchers, and curious minds all exploring how open collaboration works inside organizations.`\n }\n },\n { type: 'divider' },\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: \"👋 *Head over to <#C0867TAF63H|newcomers> and tell us a little about yourself, or choose how you'd like to get started:*\"\n }\n },\n {\n type: 'actions',\n elements: [\n { type: 'button', text: { type: 'plain_text', text: '📖 Quick Start Guide', emoji: true }, url: 'https://innersourcecommons.org/community/quick-start-guide/' },\n { type: 'button', text: { type: 'plain_text', text: '📅 Join a Meeting', emoji: true }, url: 'https://innersourcecommons.org/community/calendar/' },\n { type: 'button', text: { type: 'plain_text', text: '🏢 Pattern Library', emoji: true }, url: 'https://patterns.innersourcecommons.org/' }\n ]\n },\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: '🌍 Join a Regional Community: <#C07MXDSG2P8|africa> <#C03M546NR16|japan>'\n }\n },\n { type: 'divider' },\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: '🔎 *Explore channels that match your interests:*\\n\\n• <#C2EFRTS6A|innersource-patterns> — practical patterns for making innersource work\\n• <#C046MD5R5RT|local-community> — find or start a gathering near you\\n• <#C04DT6NQX7G|ispo-working-group> — dive into standards and best practices'\n }\n },\n { type: 'divider' },\n {\n type: 'section',\n text: {\n type: 'mrkdwn',\n text: '💬 Looking for something else? Ask in <#C04PXKRN4|general>, and the community will be happy to help!'\n }\n }\n];\nconst payload = { blocks };\nconst blockKitBuilderUrl = 'https://app.slack.com/block-kit-builder/T04PXKRM0#' + encodeURIComponent(JSON.stringify(payload));\nreturn $input.all().map(item => ({\n json: {\n ...item.json,\n blocks,\n blocks_json: JSON.stringify(payload, null, 2),\n block_kit_builder_url: blockKitBuilderUrl\n }\n}));\n"
"jsCode": "// Code comes from src/new-member-introduction/slack-welcome-message-block-kit.js at build time."
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
Expand Down
6 changes: 3 additions & 3 deletions nodes/Send Bulk DM.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nstaticData.allMembers = [];\nreturn [{ json: { cursor: '' } }];"
"jsCode": "// Code comes from src/send-bulk-dm/init-pagination.js at build time."
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
Expand Down Expand Up @@ -49,7 +49,7 @@
},
{
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nconst response = $input.first().json;\nif (response.members) {\n staticData.allMembers.push(...response.members);\n}\nconst nextCursor = response.response_metadata?.next_cursor || '';\nreturn [{ json: { cursor: nextCursor } }];"
"jsCode": "// Code comes from src/send-bulk-dm/collect-members.js at build time."
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
Expand Down Expand Up @@ -94,7 +94,7 @@
},
{
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\nconst allMembers = staticData.allMembers || [];\nreturn [{ json: { members: allMembers } }];"
"jsCode": "// Code comes from src/send-bulk-dm/output-all-members.js at build time."
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
Expand Down
4 changes: 2 additions & 2 deletions nodes/ZOOM_RECAPS_TO_SLACK.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ The JSON carries the credential ids of the ISC instance, which a different insta
## Loading a change into n8n

The workflow's n8n id is `pLIk4d8AYwAmpxpz`.
After a change to `Zoom Recaps to Slack.json` merges, load it with:
After a change to `Zoom Recaps to Slack.json` or to its code under `src/zoom-recaps-to-slack/` merges, load it with:

```bash
N8N_API_KEY=<your key> ./scripts/update-workflow.sh "nodes/Zoom Recaps to Slack.json"
```

The script sends the file to the n8n public API with a PUT.
The script fills in each Code node's code from `src/zoom-recaps-to-slack/` and sends the workflow to the n8n public API with a PUT.
Check in the editor that the workflow is still active afterwards.
Loading
Loading