Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Taucher2003 committed Dec 18, 2023
0 parents commit 3a2fd8c
Show file tree
Hide file tree
Showing 24 changed files with 8,513 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
push:
branches:
- main
pull_request:

permissions:
pull-requests: write

jobs:
pipeline:
runs-on: ubuntu-latest
steps:
- uses: Taucher2003/[email protected]
name: Run pipeline
id: pipeline
with:
GL_SERVER_URL: https://gitlab.com
GL_PROJECT_ID: '53166027'
GL_RUNNER_TOKEN: ${{ secrets.GL_RUNNER_TOKEN }}
GL_API_TOKEN: ${{ secrets.GL_API_TOKEN }}
SHOW_JOB_LOGS: all

- name: Find existing comment
uses: peter-evans/find-comment@v2
id: find-comment
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- glpa_comment:pipeline -->

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- glpa_comment:pipeline -->
${{ steps.pipeline.outputs.SUMMARY_TEXT }}
edit-mode: replace
17 changes: 17 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Mirror to GitLab

on:
push:
branches:
- main

jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git remote add gitlab https://gitlab.com/code0-tech/docs.git
- run: |
git
-c credential.helper='!f() { sleep 1; echo "username=${{ secrets.GL_API_USER }}"; echo "password=${{ secrets.GL_API_TOKEN }}"; }; f'
push gitlab build-branch
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.idea/
projects/*
!projects/docs-landing-page/

# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
26 changes: 26 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.build:
image: node:20.9.0
script:
- npm ci
- ./clone_projects.sh
- ./build.sh

build:
extends:
- .build
stage: build
rules:
- if: $CI_COMMIT_BRANCH != "build-branch"

pages:
extends:
- .build
stage: deploy
after_script:
- rm -rf public
- mv dist public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "build-branch"
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.9.0
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Starlight Starter Kit: Basics

[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)

```
npm create astro@latest -- --template starlight
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
[![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)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure

Inside of your Astro + Starlight project, you'll see the following folders and files:

```
.
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ ├── docs/
│ │ └── config.ts
│ └── env.d.ts
├── astro.config.mjs
├── package.json
└── tsconfig.json
```

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.

Images can be added to `src/assets/` and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

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).
49 changes: 49 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

const defaultConfig = {
title: 'Code0 Documentation'
}

const config = process.env.SRC_DIR
? (await import(/* @vite-ignore */`${process.env.SRC_DIR}/starlight.json`)).default
: defaultConfig;

const transformLocalLinks = () => {
return {
name: 'transform-local-links',

transform(src, id) {
if (id.endsWith('.md') || id.endsWith('.mdx')) {
const code = src
.replaceAll(/\[([^\]]+?)]\(([^)]+?)\.mdx?\)/g, "[$1](../$2/)")
.replaceAll(/href=\\"([^"]+?)\.mdx?\\"/g, "href=\\\"../$1/\\\"")
.replaceAll(/href: "([^"]+?)\.mdx?"/g, "href: \"../$1/\"");

return {
code: code,
map: null, // provide source map if available
}
}
},
}
}

// https://astro.build/config
export default defineConfig({
base: process.env.BASE_URL,
outDir: process.env.OUT_DIR ?? './dist',
srcDir: process.env.SRC_DIR ?? './src',
trailingSlash: 'always',
integrations: [
starlight(config),
],
vite: {
resolve: {
preserveSymlinks: true
},
plugins: [
transformLocalLinks(),
]
}
});
28 changes: 28 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

rm -rf dist/

build_project() {
project=$1

echo "Building $project"
mkdir -p projects/$project/content
ln $(pwd)/src/env.d.ts projects/$project/env.d.ts
ln -s $(pwd)/projects/$project/docs projects/$project/content/docs
ln $(pwd)/src/content/config.ts projects/$project/content/config.ts
if [[ "$project" != "docs-landing-page" ]]; then
export BASE_URL=/$project/
export OUT_DIR=./dist/$project
fi
SRC_DIR=$(pwd)/projects/$project npm run build
unset BASE_URL
unset OUT_DIR
rm -rf projects/$project/content
rm -rf projects/$project/env.d.ts
}

build_project "docs-landing-page"

for project in $(ls projects | grep -v docs-landing-page); do
build_project $project
done
9 changes: 9 additions & 0 deletions ci-template.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
docs:
stage: test
trigger:
project: code0-tech/docs
strategy: depend
variables:
C0_TRIGGER_PROJECT: $CI_PROJECT_NAME
C0_TRIGGER_SHA: $CI_COMMIT_SHA
C0_TRIGGER_REF: $C0_GH_REF
25 changes: 25 additions & 0 deletions clone_projects.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

shopt -s extglob
shopt -s dotglob

cd projects
rm -rf -- !(docs-landing-page)

for project in $(cat ../documentation_repositories.txt); do
git clone ${project}.git
cd $(basename "$project")

if [[ "$C0_TRIGGER_PROJECT" == "$(basename "$project")" && -n "$C0_TRIGGER_SHA" ]]; then
if [[ -n "$C0_TRIGGER_REF" ]]; then
git fetch origin $C0_TRIGGER_REF
fi
git checkout $C0_TRIGGER_SHA
fi

rm -rf -- !(docs)
rm -rf .git
mv docs/starlight.json starlight.json
cd ..
done
cd ..
Empty file added documentation_repositories.txt
Empty file.
Loading

0 comments on commit 3a2fd8c

Please sign in to comment.