Skip to content

Commit 5e3c1b1

Browse files
authored
Merge pull request #2703 from gofiber/recipes_docs
docusaurus preparations
2 parents 7830f51 + fdb7c34 commit 5e3c1b1

File tree

264 files changed

+4217
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+4217
-709
lines changed

.github/CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing Guidelines
2+
3+
Thank you for considering contributing to this project! To ensure a smooth and efficient process, please follow these guidelines.
4+
5+
## Adding a New Example
6+
7+
1. **Create a Directory**: Create a new directory for your example in the root of the repository. Please do not use a "fiber" prefix in the directory name.
8+
9+
2. **Add a `README.md`**: Each example must include a `README.md` file in its directory. This file should contain the following:
10+
11+
- **Docusaurus Metadata**: Add the following metadata at the top of the `README.md` file:
12+
```markdown
13+
---
14+
title: Your Example Title
15+
keywords: [keyword1, keyword2, keyword3]
16+
---
17+
```
18+
19+
- `title`: A short and descriptive title for your example.
20+
- `keywords`: A list of relevant keywords (excluding "fiber").
21+
22+
- **Content**: The `README.md` should provide a detailed explanation of the example, including:
23+
- The idea behind the example.
24+
- The components used in the example.
25+
- Instructions on how to run the example.
26+
- Any other relevant information.
27+
28+
3. **Update the Overview**: After adding your example, run the following command in the root directory to update the overview table of contents:
29+
```bash
30+
make generate
31+
```
32+
33+
By following these guidelines, you help maintain the quality and consistency of the project. Thank you for your contributions!

.github/scripts/sync_docs.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Some env variables
5+
BRANCH="main"
6+
REPO_URL="github.com/gofiber/docs.git"
7+
AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com"
8+
AUTHOR_USERNAME="github-actions[bot]"
9+
REPO_DIR="recipes"
10+
COMMIT_URL="https://github.com/gofiber/recipes"
11+
12+
# Set commit author
13+
git config --global user.email "${AUTHOR_EMAIL}"
14+
git config --global user.name "${AUTHOR_USERNAME}"
15+
16+
git clone https://${TOKEN}@${REPO_URL} fiber-docs
17+
18+
latest_commit=$(git rev-parse --short HEAD)
19+
20+
# remove all files in the docs directory
21+
rm -rf $ROOT/../fiberDocs/docs/${REPO_DIR}/*
22+
23+
for f in $(find -E . -type f -iregex '.*\.(md|png|jpe?g|gif|bmp|svg|webp)$' -not -path "./(fiberDocs)/*" -not -path "*/vendor/*" -not -path "*/.github/*" -not -path "*/.*"); do
24+
log_output=$(git log --oneline "${BRANCH}" HEAD~1..HEAD --name-status -- "${f}")
25+
26+
if [[ $log_output != "" || ! -f "fiber-docs/docs/${REPO_DIR}/$f" ]]; then
27+
mkdir -p fiber-docs/docs/${REPO_DIR}/$(dirname $f)
28+
cp "${f}" fiber-docs/docs/${REPO_DIR}/$f
29+
fi
30+
done
31+
32+
33+
# Push changes
34+
cd fiber-docs/ || true
35+
git add .
36+
37+
git commit -m "Add docs from ${COMMIT_URL}/commit/${latest_commit}"
38+
39+
MAX_RETRIES=5
40+
DELAY=5
41+
retry=0
42+
43+
while ((retry < MAX_RETRIES))
44+
do
45+
git push https://${TOKEN}@${REPO_URL} && break
46+
retry=$((retry + 1))
47+
git pull --rebase
48+
sleep $DELAY
49+
done
50+
51+
if ((retry == MAX_RETRIES))
52+
then
53+
echo "Failed to push after $MAX_RETRIES attempts. Exiting with 1."
54+
exit 1
55+
fi

.github/scripts/sync_local.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
if [ "$#" -eq 1 ]; then
5+
REPO_DIR="$1"
6+
else
7+
REPO_DIR="recipes" # default value
8+
fi
9+
10+
if [[ ! "$REPO_DIR" =~ ^[a-zA-Z0-9_-]+$ ]]; then
11+
echo "Error: REPO_DIR must contain only alphanumeric characters, underscores, and hyphens" >&2
12+
exit 1
13+
fi
14+
15+
# determine root repo directory
16+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
17+
18+
# remove all files in the docs directory
19+
rm -rf $ROOT/../fiberDocs/docs/${REPO_DIR}/*
20+
21+
for f in $(find -E . -type f -iregex '.*\.(md|png|jpe?g|gif|bmp|svg|webp)$' -not -path "./(fiberDocs)/*" -not -path "*/vendor/*" -not -path "*/.github/*" -not -path "*/.*"); do
22+
echo "Copying $f"
23+
mkdir -p $ROOT/../fiberDocs/docs/${REPO_DIR}/$(dirname $f)
24+
cp "${f}" $ROOT/../fiberDocs/docs/${REPO_DIR}/$f
25+
done

.github/workflows/sync-docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Sync docs'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
paths:
9+
- '**/*.md'
10+
11+
jobs:
12+
sync-docs:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
fetch-depth: 2
20+
21+
- name: Setup Node.js environment
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '18'
25+
26+
- name: Install JQ
27+
run: sudo apt-get install jq
28+
29+
- name: Sync docs
30+
run: ./.github/scripts/sync_docs.sh
31+
env:
32+
EVENT: ${{ github.event_name }}
33+
TAG_NAME: ${{ github.ref_name }}
34+
TOKEN: ${{ secrets.DOC_SYNC_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Thumbs.db
2525
*.out
2626

2727
# Dependency directories (remove the comment below to include it)
28-
# vendor/
28+
vendor/
2929

3030
# Go workspace file
3131
go.work

0 commit comments

Comments
 (0)