diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 54bc5eb15..916bafbaf 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -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 }} @@ -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 @@ -94,6 +94,71 @@ jobs: echo "Error: Close this PR and try again." exit 1 + generate-docs: + if: github.ref == 'refs/heads/develop-postgres' + runs-on: ubuntu-latest + environment: TALAWA_ENVIRONMENT + + 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@v3 + 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: "stable" + channel: "stable" + + # Step 4: Set up Dart + - name: Set up Dart + uses: dart-lang/setup-dart@v1 + with: + sdk: "stable" + + # 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 + dart analyze + flutter pub global activate dartdoc + flutter pub global run dartdoc --output docs/docs/auto-docs/dart + + # Step 6: Generate Java Documentation + - name: Generate Java Docs + run: | + javadoc -d docs/docs/auto-docs/java -sourcepath src -subpackages com.example + + # 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') }} @@ -241,22 +306,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 + working-directory: ../docs + run: npm install + - name: Test building the website - working-directory: ./docs - run: yarn build + working-directory: ../docs + run: npm run build Validate-Coderabbit: name: Validate CodeRabbit Approval