Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Auto docs using Github Action #2713

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
102 changes: 89 additions & 13 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: PR Workflow
on:
pull_request:
branches-ignore:
- 'master'
- "master"

env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}
Expand All @@ -33,12 +33,12 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17.0'
distribution: "zulu" # See 'Supported distributions' for available options
java-version: "17.0"
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
flutter-version: "3.22.3"
channel: "stable" # or: 'beta', 'dev' or 'master'
- name: Set default branch.
run: git remote set-head origin --auto
shell: bash
Expand Down Expand Up @@ -94,6 +94,79 @@ jobs:
echo "Error: Close this PR and try again."
exit 1

generate-docs:
if: github.ref == 'refs/heads/develop-postgres' || (github.event_name == 'pull_request' && github.base_ref == 'develop-postgres')
runs-on: ubuntu-latest
environment: TALAWA_ENVIRONMENT
hars-21 marked this conversation as resolved.
Show resolved Hide resolved
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: GITHUB_TOKEN is not set"
exit 1
fi

steps:
# Step 1: Check out the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Set up Java
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "zulu" # Adjust if required
java-version: "17" # Use a modern version suitable for your project

# Step 3: Set up Flutter
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.22.3"
channel: "stable"

# Step 4: Set up Dart
- name: Set up Dart
uses: dart-lang/setup-dart@v1
with:
sdk: "3.4.4"

# Step 5: Generate Dart and Flutter Documentation
- name: Generate Dart and Flutter Docs
run: |
cd talawa_lint && flutter pub get && cd ..
flutter pub get
flutter analyze --no-fatal-infos
flutter pub global activate dartdoc flutter pub global run dartdoc \
--output docs/docs/auto-docs/dart \
--exclude 'dart:async,dart:collection,dart:convert,dart:core,dart:developer,dart:io' \
--no-generate-docs-for-dependencies \
--warnings-as-errors
# Step 6: Generate Java Documentation
- name: Generate Java Docs
run: |
find . -name "*.java" > sources.txt
javadoc -d docs/docs/auto-docs/java @sources.txt
# Step 7: Check for Documentation Updates
- name: Check for Doc Updates
id: DocUpdated
run: |
if [ -n "$(git status --porcelain docs/docs/auto-docs)" ]; then
echo "updateDoc=true" >> $GITHUB_OUTPUT
echo "Documentation has been updated!"
else
echo "No documentation updates found."
fi

# Step 8: Commit and Push Updates
- name: Commit and Push Docs
if: steps.DocUpdated.outputs.updateDoc
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add docs/docs/auto-docs
git commit -m "Update auto-generated documentation"
git push

Branch-check:
if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }}
Expand Down Expand Up @@ -241,22 +314,25 @@ jobs:
name: Test Deployment to https://docs-mobile.talawa.io
runs-on: ubuntu-latest
needs: [iOS-Build, Android-Build]
# Run only if the develop-postgres branch and not dependabot
# Run only if the develop-postgres branch and not dependabot
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.base.ref == 'develop-postgres' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout the Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
cache-dependency-path: 'docs/'
node-version: "20.x"

# Run Docusaurus in the ./docs directory
- name: Install dependencies
working-directory: ./docs
run: yarn install --frozen-lockfile
run: npm install

- name: Test building the website
working-directory: ./docs
run: yarn build
run: npm run build

Validate-Coderabbit:
name: Validate CodeRabbit Approval
Expand Down
93 changes: 47 additions & 46 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
{
"name": "docs",
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"docusaurus": "^1.14.7",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.3",
"@docusaurus/tsconfig": "3.6.3",
"@docusaurus/types": "3.6.3",
"typescript": "~5.6.2"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 3 chrome version",
"last 3 firefox version",
"last 5 safari version"
]
},
"engines": {
"node": ">=18.0"
}
"name": "docs",
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc",
"generate-docs": "cd .. && flutter pub global run dartdoc . --output docs/docs/auto-docs"
},
"dependencies": {
"@docusaurus/core": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"docusaurus": "^1.14.7",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.3",
"@docusaurus/tsconfig": "3.6.3",
"@docusaurus/types": "3.6.3",
"typescript": "~5.6.2"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 3 chrome version",
"last 3 firefox version",
"last 5 safari version"
]
},
"engines": {
"node": ">=18.0"
}
}
Loading