Skip to content

Commit b4be619

Browse files
authored
Merge pull request #1 from ahoy-cli/in-progress
Docs in progress - test Astro staging workflow
2 parents aa2dbb8 + dadcc0c commit b4be619

29 files changed

Lines changed: 11093 additions & 23 deletions

.github/workflows/deploy-docs.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: ['main', 'develop', 'staging']
6+
pull_request:
7+
branches: ['main']
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
pull-requests: write
15+
16+
concurrency:
17+
group: 'docs-${{ github.ref }}'
18+
cancel-in-progress: true
19+
20+
env:
21+
# Determine deployment environment based on branch
22+
DEPLOY_ENV: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
deploy-env: ${{ env.DEPLOY_ENV }}
29+
base-url: ${{ steps.base-url.outputs.url }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '22'
38+
cache: 'npm'
39+
40+
- name: Setup Pages (production only)
41+
if: github.ref_name == 'main'
42+
id: pages
43+
uses: actions/configure-pages@v4
44+
45+
- name: Determine base URL
46+
id: base-url
47+
run: |
48+
if [[ "${{ github.ref_name }}" == "main" ]]; then
49+
echo "url=" >> $GITHUB_OUTPUT
50+
else
51+
echo "url=/docs-${{ github.ref_name }}" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Build documentation
58+
run: npm run build
59+
env:
60+
# Set base URL for non-production builds
61+
BASE_URL: ${{ steps.base-url.outputs.url }}
62+
63+
- name: Upload artifact (production)
64+
if: github.ref_name == 'main'
65+
uses: actions/upload-pages-artifact@v3
66+
with:
67+
path: ./dist
68+
69+
- name: Upload artifact (staging)
70+
if: github.ref_name != 'main'
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: docs-${{ github.ref_name }}
74+
path: ./dist
75+
retention-days: 30
76+
77+
deploy-production:
78+
if: github.ref_name == 'main'
79+
environment:
80+
name: github-pages
81+
url: ${{ steps.deployment.outputs.page_url }}
82+
runs-on: ubuntu-latest
83+
needs: build
84+
steps:
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v4
88+
89+
deploy-staging:
90+
if: github.ref_name != 'main' && github.event_name == 'push'
91+
runs-on: ubuntu-latest
92+
needs: build
93+
steps:
94+
- name: Checkout gh-pages
95+
uses: actions/checkout@v4
96+
with:
97+
ref: gh-pages
98+
token: ${{ secrets.GITHUB_TOKEN }}
99+
fetch-depth: 0
100+
101+
- name: Download staging artifact
102+
uses: actions/download-artifact@v4
103+
with:
104+
name: docs-${{ github.ref_name }}
105+
path: ./temp-staging
106+
107+
- name: Deploy to staging directory
108+
run: |
109+
# Create staging directory
110+
mkdir -p docs-${{ github.ref_name }}
111+
112+
# Copy built docs to staging directory
113+
cp -r temp-staging/* docs-${{ github.ref_name }}/
114+
115+
# Clean up temp directory
116+
rm -rf temp-staging
117+
118+
# Configure git
119+
git config user.name "github-actions[bot]"
120+
git config user.email "github-actions[bot]@users.noreply.github.com"
121+
122+
# Commit changes
123+
git add docs-${{ github.ref_name }}
124+
git commit -m "Deploy staging docs for ${{ github.ref_name }}" || exit 0
125+
git push
126+
127+
- name: Comment on PR with staging link
128+
if: github.event_name == 'pull_request'
129+
uses: actions/github-script@v7
130+
with:
131+
script: |
132+
const stagingUrl = `https://ahoy-cli.github.io/docs-${{ github.ref_name }}/`;
133+
const comment = `📖 **Documentation Preview**
134+
135+
Staging documentation is available at: ${stagingUrl}
136+
137+
This preview will be updated automatically with new commits to this branch.`;
138+
139+
github.rest.issues.createComment({
140+
issue_number: context.issue.number,
141+
owner: context.repo.owner,
142+
repo: context.repo.repo,
143+
body: comment
144+
});

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# build output
2+
dist/
3+
# generated types
4+
.astro/
5+
6+
# dependencies
7+
node_modules/
8+
9+
# logs
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
pnpm-debug.log*
14+
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

astro-starlight-README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Starlight Starter Kit: Basics
2+
3+
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
4+
5+
```
6+
npm create astro@latest -- --template starlight
7+
```
8+
9+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
10+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
11+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics)
12+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)
13+
14+
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
15+
16+
## 🚀 Project Structure
17+
18+
Inside of your Astro + Starlight project, you'll see the following folders and files:
19+
20+
```
21+
.
22+
├── public/
23+
├── src/
24+
│ ├── assets/
25+
│ ├── content/
26+
│ │ ├── docs/
27+
│ └── content.config.ts
28+
├── astro.config.mjs
29+
├── package.json
30+
└── tsconfig.json
31+
```
32+
33+
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
34+
35+
Images can be added to `src/assets/` and embedded in Markdown with a relative link.
36+
37+
Static assets, like favicons, can be placed in the `public/` directory.
38+
39+
## 🧞 Commands
40+
41+
All commands are run from the root of the project, from a terminal:
42+
43+
| Command | Action |
44+
| :------------------------ | :----------------------------------------------- |
45+
| `npm install` | Installs dependencies |
46+
| `npm run dev` | Starts local dev server at `localhost:4321` |
47+
| `npm run build` | Build your production site to `./dist/` |
48+
| `npm run preview` | Preview your build locally, before deploying |
49+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
50+
| `npm run astro -- --help` | Get help using the Astro CLI |
51+
52+
## 👀 Want to learn more?
53+
54+
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).

astro.config.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
import starlight from '@astrojs/starlight';
4+
import starlightThemeRapide from 'starlight-theme-rapide';
5+
6+
// https://astro.build/config
7+
export default defineConfig({
8+
integrations: [
9+
starlight({
10+
title: 'Ahoy',
11+
description: 'Create self-documenting CLI programs with ease, using YAML files in your source tree',
12+
customCss: [
13+
'./src/styles/custom.css',
14+
],
15+
// plugins: [
16+
// starlightThemeRapide(),
17+
// ],
18+
social: {
19+
github: 'https://github.com/ahoy-cli/ahoy',
20+
},
21+
sidebar: [
22+
{
23+
label: 'Getting Started',
24+
items: [
25+
{ label: 'Installation & Setup', slug: 'guides/getting-started' },
26+
{ label: 'Shell Autocompletion', slug: 'guides/shell-autocompletion' },
27+
],
28+
},
29+
{
30+
label: 'Guides',
31+
items: [
32+
{ label: 'YAML Configuration', slug: 'guides/yaml-config' },
33+
{ label: 'Command Execution', slug: 'guides/command-execution' },
34+
{ label: 'Importing & Overriding', slug: 'guides/importing' },
35+
{ label: 'Environment', slug: 'guides/environment' },
36+
],
37+
},
38+
{
39+
label: 'Reference',
40+
items: [
41+
{ label: 'CLI Reference', slug: 'reference/cli' },
42+
{ label: 'Environment Reference', slug: 'reference/environment' },
43+
{ label: 'YAML Schema', slug: 'reference/yaml-schema' },
44+
],
45+
},
46+
{
47+
label: 'Top',
48+
items: [
49+
{ label: 'Installation', slug: 'installation' },
50+
{ label: 'Introduction', slug: 'introduction' },
51+
{ label: 'Quick Start', slug: 'quick-start' },
52+
],
53+
},
54+
],
55+
}),
56+
],
57+
});

0 commit comments

Comments
 (0)