Skip to content

Commit

Permalink
#2970: autoGen-talawa-admin-docs-debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
bint-Eve committed Jan 7, 2025
1 parent 061a3a0 commit 21539ef
Showing 1 changed file with 39 additions and 52 deletions.
91 changes: 39 additions & 52 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,28 +500,30 @@ jobs:
name: Generate Auto Documentation
runs-on: ubuntu-latest
needs: [Code-Quality-Checks, Test-Application, Start-App-Without-Docker, Docker-Start-Check]

steps:
- uses: actions/checkout@v4
# Step 1: Checkout the code
- name: Checkout Code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0 # Required for getting full git history
PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0

# Step 2: Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'npm'

- name: Install dependencies
# Step 3: Install dependencies
- name: Install Dependencies
run: |
npm ci
npm install -g typedoc typedoc-plugin-markdown
# Step 4: Generate Documentation
- name: Generate Documentation
run: |
# Generate the documentation
typedoc \
--out docs/docs/auto-docs \
--plugin typedoc-plugin-markdown \
Expand All @@ -540,62 +542,47 @@ jobs:
--exclude "**/node_modules/**" \
--cleanOutputDir true
- name: Create placeholder documentation
# Step 5: Create placeholder documentation (only if not present)
- name: Create Placeholder Documentation
run: |
# Create User Guide placeholder
echo "# User Guide
This section contains the user guide for Talawa Admin.
" > docs/docs/user-guide/intro.md
mkdir -p docs/docs/user-guide
mkdir -p docs/docs/developer-guide/reference
# Create Developer Guide placeholder
echo "# Developer Guide
This section contains the developer guide for Talawa Admin.
" > docs/docs/developer-guide/intro.md
if [ ! -f docs/docs/user-guide/intro.md ]; then
echo "# User Guide\n\nThis section contains the user guide for Talawa Admin." > docs/docs/user-guide/intro.md
fi
# Create Reference placeholder
echo "# API Reference
This section contains the auto-generated API documentation for Talawa Admin.
" > docs/docs/developer-guide/reference/README.md
if [ ! -f docs/docs/developer-guide/intro.md ]; then
echo "# Developer Guide\n\nThis section contains the developer guide for Talawa Admin." > docs/docs/developer-guide/intro.md
fi
if [ ! -f docs/docs/developer-guide/reference/README.md ]; then
echo "# API Reference\n\nThis section contains the auto-generated API documentation for Talawa Admin." > docs/docs/developer-guide/reference/README.md
fi
# Step 6: Set up Git configuration
- name: Setup Git Config
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Debug GitHub Variables
run: |
echo "GitHub REF: ${{ github.ref }}"
echo "GitHub HEAD REF: ${{ github.head_ref }}"
echo "GitHub BASE REF: ${{ github.base_ref }}"
echo "GitHub REF NAME: ${{ github.ref_name }}"
echo "GitHub EVENT NAME: ${{ github.event_name }}"
echo "Current branch:"
git branch --show-current
echo "All branches:"
git branch -a
echo "Git status:"
git status
- name: Check and Commit Documentation
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Step 7: Check and Commit Changes
- name: Commit Documentation Changes
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Set the remote URL with PAT for authentication
git remote set-url origin https://${PAT}@github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}.git
git remote set-url origin https://${GITHUB_TOKEN}@github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}.git
git fetch origin ${{ github.ref_name }}
git checkout ${{ github.ref_name }}
git add docs/docs/auto-docs/
git add docs/docs/developer-guide/
git add docs/docs/user-guide/
if [[ -n "$(git status --porcelain)" ]]; then
if [ -n "$(git status --porcelain)" ]; then
git commit -m "docs: update auto-generated documentation [skip ci]"
# Use PAT in the push command
git push "https://${PAT}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git" HEAD:${{ github.head_ref }}
git push origin HEAD:${{ github.ref_name }}
else
echo "No changes to commit"
echo "No changes to commit."
fi

0 comments on commit 21539ef

Please sign in to comment.