Skip to content
Open
Show file tree
Hide file tree
Changes from 20 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
59 changes: 0 additions & 59 deletions .dockerignore

This file was deleted.

170 changes: 127 additions & 43 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,135 @@
name: Create and publish a Docker image

name: Deploy Docs
on:
release:
types:
- created
push:
branches:
- main
- next
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
WRANGLER_VERSION: "4.50.0"
CF_ACCOUNT_ID: "a0fd0b38598331045fc0c76fadadbe29"

jobs:
build-and-push-image:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Dart SDK
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Cache Dart packages
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-
- name: Install dependencies
run: dart pub get

- name: Build documentation
run: dart run jaspr_cli:jaspr build

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-jaspr
path: build/jaspr

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.TOKEN_PUSH_IMAGE }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
PROD_URL=${{ secrets.PROD_URL }}
REPO_NAME_PROD=${{ secrets.REPO_NAME_PROD }}
REPO_BRANCH_NAME=${{ secrets.REPO_BRANCH_NAME }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# - name: Redeploy portainer
# uses: muinmomin/[email protected]
# with:
# url: ${{ secrets.ROD_PORTAINER_WEBHOOK }}
- uses: actions/checkout@v6

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-jaspr
path: build/jaspr

- name: Deploy Preview (Pull Request)
id: deploy
if: ${{ github.event_name == 'pull_request' }}
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ env.CF_ACCOUNT_ID }}
wranglerVersion: ${{ env.WRANGLER_VERSION }}
command: pages deploy build/jaspr --project-name nyxx-docs
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ env.CF_ACCOUNT_ID }}
- name: Add PR comment
if: ${{ steps.deploy.outcome == 'success' }}
uses: actions/github-script@v8
env:
STEPS: ${{ toJson(steps) }}
with:
script: |
const steps = JSON.parse(process.env.STEPS);
const prNumber = context.issue.number;
const commentTag = '<!-- docs-preview-url -->';

const output = steps.deploy.outputs['command-output'];
const urlRegex = /Deployment complete! Take a peek over at\s+(https:\/\/[^\s]+)/;
const match = output?.match(urlRegex);
const previewUrl = match ? match[1] : null;

const body = previewUrl
? `${commentTag}\n🌙 Docs Preview available at: ${previewUrl}`
: `${commentTag}\n⚠️ Could not determine preview URL.`;

const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: prNumber,
});

const existingComment = comments.find(comment =>
comment.body.includes(commentTag)
);

if (existingComment) {
await github.rest.issues.updateComment({
...context.repo,
comment_id: existingComment.id,
body,
});
} else {
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body,
});
}

console.log('Preview URL comment added/updated.');

- name: Deploy Next (Staging)
if: ${{ github.ref == 'refs/heads/next' && github.event_name == 'push' }}
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: ${{ env.WRANGLER_VERSION }}
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ env.CF_ACCOUNT_ID }}
command: pages deploy build/jaspr --project-name nyxx-docs --branch next
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ env.CF_ACCOUNT_ID }}

- name: Deploy Production
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: ${{ env.WRANGLER_VERSION }}
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ env.CF_ACCOUNT_ID }}
command: pages deploy build/jaspr --project-name nyxx-docs
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ env.CF_ACCOUNT_ID }}
49 changes: 27 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
/dist
.idea/
.vscode/*
!.vscode/
!.vscode/extensions.json
node_modules/
package-lock.json
/base/generated_styles.css
# Prodution
build/
# Files and directories created by pub.
**/doc/api/
.dart_tool/
.packages

# Generated files
.docusaurus
.cache-loader
# Conventional directory for build output.
/build/

# Misc
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
pubspec.lock

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"Dart-Code.dart-code",
"schultek.jaspr-code",
]
}
26 changes: 19 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# Contributing

Nyxx is free and open-source project, and all contributions are welcome and highly appreciated. However, please conform to the following guidelines when possible.
nyxx is free and open-source project, and all contributions are welcome and highly appreciated. However, please conform to the following guidelines when possible.

## Writing docs
Docs are written in markdown format and compiled with the [docusaurus](https://docusaurus.io) package.
Docs are written in markdown format and compiled with the [jaspr](https://jaspr.site) package.

Our environement is Nodejs for SSR (Server side rendering)\* TypeScript React to render components; so you need to understand the fundamentals of typescript and React.
We're also using [pnpm](https://pnpm.io) as the package manager for this project, you can simply install it by executing `npm i -g pnpm`.
To preview your changes locally, run the following command in the root of the repository:

You can compile the documentation by executing `pnpm build`; then execute `pnpm serve` to navigate trough the compiled docs.
```bash
dart run jaspr_cli:jaspr serve
```

If you're developing, use the `pnpm start` command that will render instantanly the changes you've made in the markdown docs or the components.
This will start a local server at `http://localhost:8080` where you can see your changes in real-time.

\* Even if it's all static files, docusaurus is a mix between SSR and SSG (Static site generation) - [Read here for more explanations](https://docusaurus.io/docs/advanced/ssg)
When writing docs, please ensure that:
- The content is clear, concise, and easy to understand.
- The formatting is consistent with the rest of the documentation.

When writing components, please ensure that you follow [Jaspr's component system](https://docs.jaspr.site/concepts/components).

## Building the site
To build the site for deployment, run the following command in the root of the repository:
```bash
dart run jaspr_cli:jaspr build
```
This will generate the static files in the `build` directory, which can then be deployed to a web server.
22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# [nyxx](https://github.com/nyxx-discord/nyxx) Documentation
# nyxx_docs

Documentation and guides for the [nyxx](https://github.com/nyxx-discord/nyxx) discord api library
A documentation site built with Jaspr

## Info
## Running the project

This repo contains documentation and guide to help people with learning dart and creating discord bots with nyxx. Many subjects are cover such as:
- How to create a bot account
- Setting up a basic hello world project
- Picking your message intents
- Using interactions
- and more.
Run your project using `jaspr serve`.

## Contributing
The development server will be available on `http://localhost:8080`.

If you're interested in contributing to the documentation or guides, you should check out our [GitHub Projects](https://github.com/nyxx-discord/nyxx-docs/projects) page or [open issues](https://github.com/nyxx-discord/nyxx-docs/issues). There's a [contribution guide](./CONTRIBUTING.md) you should read once you decide on what you want to contribute.
## Building the project

Build your project using `jaspr build`.

The output will be located inside the `build/jaspr/` directory.
Loading