Skip to content

Commit 6add2a3

Browse files
committed
fix opensearch.xml generation
1 parent 1d224cb commit 6add2a3

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

.github/workflows/static.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ concurrency:
1515
group: "deploy-pages"
1616
cancel-in-progress: false
1717

18-
env:
19-
I4K_FIND_URL: ${{ vars.I4K_FIND_URL }}
20-
2118
jobs:
2219
deploy:
2320
environment:
@@ -28,6 +25,10 @@ jobs:
2825
- name: Checkout repository
2926
uses: actions/checkout@v4
3027

28+
- name: Configure GitHub Pages
29+
id: pages
30+
uses: actions/configure-pages@v5
31+
3132
- name: Setup Node.js
3233
uses: actions/setup-node@v3
3334
with:
@@ -37,11 +38,11 @@ jobs:
3738
run: npm ci
3839

3940
- name: Generate opensearch.xml
41+
env:
42+
# Use custom URL if set, otherwise use the GitHub Pages base URL
43+
I4K_FIND_URL: ${{ vars.I4K_FIND_URL || steps.pages.outputs.base_url }}
4044
run: npm run opensearch assets/opensearch.xml
4145

42-
- name: Configure GitHub Pages
43-
uses: actions/configure-pages@v5
44-
4546
- name: Upload Pages artifact
4647
uses: actions/upload-pages-artifact@v3
4748
with:

docs/deployment.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ For more customization, see the development documentation.
55

66
## Methods
77
There are diverse possibilities to deploy a new instance with a custom
8-
Find, generally it will need the correct values for the `I4K_FIND_URL`
9-
environment variable, `https://example.org/my-find`. As reference,
10-
check the different CI/CD workflow recipes.
8+
Find. The OpenSearch configuration is generated from the `I4K_FIND_URL`
9+
environment variable (e.g., `https://example.org/my-find`).
10+
11+
**For GitHub Pages deployments**: The `I4K_FIND_URL` automatically defaults
12+
to your repository's GitHub Pages URL, so no manual configuration is needed.
13+
14+
**For custom domains**: Set the `I4K_FIND_URL` environment variable to your
15+
deployment URL. As reference, check the different CI/CD workflow recipes.
1116

1217
> The recommended method is to use a CI/CD recipe to deploy a custom
1318
> instance, to a custom server (or pages like the default
@@ -39,11 +44,13 @@ Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=
3944
### github fork & actions (for own instance)
4045
- fork this repository
4146
- enable "pages from actions" in the settings
42-
- customize the `I4K_FIND_URL` env var (it will try to default to the
43-
github pages deployment URL)
4447
- run the "static.yml" workflow
4548
- visit the fork's github page
4649

50+
**Note**: The `I4K_FIND_URL` environment variable automatically defaults to
51+
your GitHub Pages URL (`https://{owner}.github.io/{repo}/`). You only need
52+
to set it manually in repository variables if deploying to a custom domain.
53+
4754
### gitlab pages
4855
- fork this repository on gitlab
4956
- it should use the `pages` job/pipeline, that will deploy a new instance

src/scripts/opensearch-xml.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { OpenSearchDescription } from "../open-search.js";
2-
import packageJson from "../../package.json" assert { type: "json" };
2+
import packageJson from "../../package.json" with { type: "json" };
33
import fs from "fs/promises";
44
import path from "path";
55

@@ -48,9 +48,13 @@ const openSearchXml = async () => {
4848
const { I4K_FIND_URL } = process.env;
4949

5050
if (!I4K_FIND_URL) {
51+
console.error("ERROR: I4K_FIND_URL environment variable is not set");
52+
console.error("The OpenSearch XML file will not be generated.");
5153
return;
5254
}
5355

56+
console.log(`Generating OpenSearch XML for: ${I4K_FIND_URL}`);
57+
5458
let osdXml;
5559
try {
5660
const newConfig = await newUserConfig(I4K_FIND_URL);
@@ -65,6 +69,7 @@ const openSearchXml = async () => {
6569
try {
6670
const localPath = path.join(process.cwd(), OSD_PATH);
6771
await fs.writeFile(localPath, osdXml);
72+
console.log(`✓ OpenSearch XML written to: ${localPath}`);
6873
} catch (e) {
6974
throw e;
7075
}

0 commit comments

Comments
 (0)