-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2703 from gofiber/recipes_docs
docusaurus preparations
- Loading branch information
Showing
264 changed files
with
4,217 additions
and
709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Contributing Guidelines | ||
|
||
Thank you for considering contributing to this project! To ensure a smooth and efficient process, please follow these guidelines. | ||
|
||
## Adding a New Example | ||
|
||
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. | ||
|
||
2. **Add a `README.md`**: Each example must include a `README.md` file in its directory. This file should contain the following: | ||
|
||
- **Docusaurus Metadata**: Add the following metadata at the top of the `README.md` file: | ||
```markdown | ||
--- | ||
title: Your Example Title | ||
keywords: [keyword1, keyword2, keyword3] | ||
--- | ||
``` | ||
|
||
- `title`: A short and descriptive title for your example. | ||
- `keywords`: A list of relevant keywords (excluding "fiber"). | ||
|
||
- **Content**: The `README.md` should provide a detailed explanation of the example, including: | ||
- The idea behind the example. | ||
- The components used in the example. | ||
- Instructions on how to run the example. | ||
- Any other relevant information. | ||
|
||
3. **Update the Overview**: After adding your example, run the following command in the root directory to update the overview table of contents: | ||
```bash | ||
make generate | ||
``` | ||
|
||
By following these guidelines, you help maintain the quality and consistency of the project. Thank you for your contributions! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Some env variables | ||
BRANCH="main" | ||
REPO_URL="github.com/gofiber/docs.git" | ||
AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com" | ||
AUTHOR_USERNAME="github-actions[bot]" | ||
REPO_DIR="recipes" | ||
COMMIT_URL="https://github.com/gofiber/recipes" | ||
|
||
# Set commit author | ||
git config --global user.email "${AUTHOR_EMAIL}" | ||
git config --global user.name "${AUTHOR_USERNAME}" | ||
|
||
git clone https://${TOKEN}@${REPO_URL} fiber-docs | ||
|
||
latest_commit=$(git rev-parse --short HEAD) | ||
|
||
# remove all files in the docs directory | ||
rm -rf $ROOT/../fiberDocs/docs/${REPO_DIR}/* | ||
|
||
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 | ||
log_output=$(git log --oneline "${BRANCH}" HEAD~1..HEAD --name-status -- "${f}") | ||
|
||
if [[ $log_output != "" || ! -f "fiber-docs/docs/${REPO_DIR}/$f" ]]; then | ||
mkdir -p fiber-docs/docs/${REPO_DIR}/$(dirname $f) | ||
cp "${f}" fiber-docs/docs/${REPO_DIR}/$f | ||
fi | ||
done | ||
|
||
|
||
# Push changes | ||
cd fiber-docs/ || true | ||
git add . | ||
|
||
git commit -m "Add docs from ${COMMIT_URL}/commit/${latest_commit}" | ||
|
||
MAX_RETRIES=5 | ||
DELAY=5 | ||
retry=0 | ||
|
||
while ((retry < MAX_RETRIES)) | ||
do | ||
git push https://${TOKEN}@${REPO_URL} && break | ||
retry=$((retry + 1)) | ||
git pull --rebase | ||
sleep $DELAY | ||
done | ||
|
||
if ((retry == MAX_RETRIES)) | ||
then | ||
echo "Failed to push after $MAX_RETRIES attempts. Exiting with 1." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if [ "$#" -eq 1 ]; then | ||
REPO_DIR="$1" | ||
else | ||
REPO_DIR="recipes" # default value | ||
fi | ||
|
||
if [[ ! "$REPO_DIR" =~ ^[a-zA-Z0-9_-]+$ ]]; then | ||
echo "Error: REPO_DIR must contain only alphanumeric characters, underscores, and hyphens" >&2 | ||
exit 1 | ||
fi | ||
|
||
# determine root repo directory | ||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" | ||
|
||
# remove all files in the docs directory | ||
rm -rf $ROOT/../fiberDocs/docs/${REPO_DIR}/* | ||
|
||
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 | ||
echo "Copying $f" | ||
mkdir -p $ROOT/../fiberDocs/docs/${REPO_DIR}/$(dirname $f) | ||
cp "${f}" $ROOT/../fiberDocs/docs/${REPO_DIR}/$f | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: 'Sync docs' | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
paths: | ||
- '**/*.md' | ||
|
||
jobs: | ||
sync-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 2 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install JQ | ||
run: sudo apt-get install jq | ||
|
||
- name: Sync docs | ||
run: ./.github/scripts/sync_docs.sh | ||
env: | ||
EVENT: ${{ github.event_name }} | ||
TAG_NAME: ${{ github.ref_name }} | ||
TOKEN: ${{ secrets.DOC_SYNC_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.