Skip to content
Merged
27 changes: 16 additions & 11 deletions .github/workflows/create-plugin-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: contains(github.event.issue.labels.*.name, 'plugin-submission')
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
- uses: actions/github-script@v8
with:
script: |
const body = context.payload.issue.body ?? '';
Expand Down Expand Up @@ -96,34 +96,37 @@ jobs:
});
return;
} catch (e) {
if (e.status !== 404) throw e;
// File doesn't exist — expected
}

// Generate YAML
const yamlScalar = (value) => (value == null ? 'null' : JSON.stringify(value));

const yamlLines = [
'# yaml-language-server: $schema=https://docusaurus.community/schema/plugin/1.0.0.json',
`id: ${id}`,
`name: "${name.replace(/"/g, '\\"')}"`,
`description: "${description.replace(/"/g, '\\"')}"`,
`preview: ${preview || 'null'}`,
`website: ${website}`,
`source: ${source || 'null'}`,
`author: ${author || 'null'}`,
`name: ${yamlScalar(name)}`,
`description: ${yamlScalar(description)}`,
`preview: ${yamlScalar(preview)}`,
`website: ${yamlScalar(website)}`,
`source: ${yamlScalar(source)}`,
`author: ${yamlScalar(author)}`,
];

if (tags.length > 0) {
yamlLines.push('tags:');
tags.forEach(t => yamlLines.push(` - ${t}`));
tags.forEach(t => yamlLines.push(` - ${yamlScalar(t)}`));
} else {
yamlLines.push('tags: []');
}

yamlLines.push(`minimumVersion: ${minimumVersion || 'null'}`);
yamlLines.push(`status: ${status}`);
yamlLines.push(`minimumVersion: ${yamlScalar(minimumVersion)}`);
yamlLines.push(`status: ${yamlScalar(status)}`);

if (npmPackages.length > 0) {
yamlLines.push('npmPackages:');
npmPackages.forEach(p => yamlLines.push(` - ${p}`));
npmPackages.forEach(p => yamlLines.push(` - ${yamlScalar(p)}`));
} else {
yamlLines.push('npmPackages: []');
}
Expand All @@ -148,6 +151,8 @@ jobs:
sha: baseSha,
});
} catch (e) {
// 422 is returned when the ref already exists
if (e.status !== 422) throw e;
actualBranch = `${branch}-${issueNumber}`;
await github.rest.git.createRef({
owner: context.repo.owner,
Expand Down
6 changes: 3 additions & 3 deletions contributing/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The plugin directory is powered by [`@homotechsual/docusaurus-plugin-showcase`](

## Before you submit

- If the plugin is **open source** the source repository must be publicly accessible and present in the `source` field of your YAML file.
- If the plugin is **closed source** the source repository must not be present in the `source` field of your YAML file.
- The plugin must work with a current or recent stable release of Docusaurus to have `status` set to `maintained`. If the plugin is no longer maintained, set `status` to `unmaintained`. If you are unsure, set `status` to `unknown`.
- If the plugin is **open source**, the source repository must be publicly accessible and provided in the `source` field of your YAML file.
- If the plugin is **closed source**, set the `source` field to `null` (or omit the field entirely).
- Set `status` to `maintained` only if the plugin works with a current or recent stable release of Docusaurus. If the plugin is no longer maintained, set `status` to `unmaintained`. If you are unsure, set `status` to `unknown`.
- One entry per npm package (or logical plugin unit).

## Create your YAML file
Expand Down