Skip to content

Commit

Permalink
uild: add documentation PR builder check
Browse files Browse the repository at this point in the history
  • Loading branch information
Achintha Isuru committed Aug 20, 2024
1 parent 2a8a205 commit de47796
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ concurrency:
env:
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
DOC_DIR: docs
DOCS_SCRIPT_DIR: .github/workflows/scripts/docs

jobs:
deploy:
Expand Down Expand Up @@ -85,7 +86,7 @@ jobs:
distribution: "adopt"

- name: 🤖 Generate Android SDK API Docs
working-directory: .github/workflows/scripts/docs/android
working-directory: ${{ env.DOCS_SCRIPT_DIR }}/android
run: bash ./dokka_build.sh

- name: 🌩 Upload artifact
Expand Down
124 changes: 101 additions & 23 deletions .github/workflows/pr-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ on:
types: [ opened, synchronize, labeled ]
branches: [ main ]
paths-ignore:
- "**/*.md"
- "**/LICENSE"

concurrency:
Expand All @@ -36,43 +35,79 @@ concurrency:

env:
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
ANDROID_SCRIPT_DIR: .github/workflows/scripts/android
DOCS_SCRIPT_DIR: .github/workflows/scripts/docs
DOC_DIR: docs

jobs:
check_for_android_changes:
name: 🤖 🔄 Check for Android Changes
check_for_relevant_changes:
name: 🔄 Check for Relevant Changes
runs-on: ubuntu-latest
outputs:
android_changed: ${{ steps.validate_android_changes.outputs.android_changed }}
android_changed: ${{ steps.check_android_changes.outputs.android_changed }}
documentation_changed: ${{ steps.check_documentation_changes.outputs.documentation_changed }}
steps:
- name: ⬇️ Checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# token: ${{ env.GH_TOKEN }}
- name: ⬇️ Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ env.GH_TOKEN }}

- name: ✅ Validate Android Changes
id: validate_android_changes
run: |
echo "Checking for Android changes"
android_changed=false
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "android"; then
android_changed=true
fi
echo "android_changed=${android_changed}" >> $GITHUB_OUTPUT
- name: 🌴 Fetch PR branch
run: |
if [ ${{ github.event.pull_request.head.repo.fork }} == true ]; then
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }}
else
git fetch origin ${{ github.head_ref }}
fi
- name: 🗃️ Get changed files
id: changed-files
run: |
if [ ${{ github.event.pull_request.head.repo.fork }} == true ]; then
echo "Comparing changes for PR from fork"
git diff --name-only origin/${{ github.base_ref }}..pr-${{ github.event.pull_request.number }} > changed_files.txt
else
echo "Comparing changes for internal PR"
git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} > changed_files.txt
fi
echo "Changed files:"
cat changed_files.txt
- name: 🤖 Check for Android Changes
id: check_android_changes
run: |
echo "Checking for Android changes"
android_changed=false
if grep -q "android/" changed_files.txt; then
android_changed=true
echo "Android changes detected"
fi
echo "android_changed=${android_changed}" >> $GITHUB_OUTPUT
- name: 📑 Check for Documentation Changes
id: check_documentation_changes
run: |
echo "Checking for Documentation changes"
documentation_changed=false
if grep -q "docs/" changed_files.txt; then
documentation_changed=true
echo "Documentation changes detected"
fi
echo "documentation_changed=${documentation_changed}" >> $GITHUB_OUTPUT
asgardeo-android-sdk-builder:
name: 🤖 🚧 Asgardeo Android SDK Builder
needs: check_for_android_changes
if: needs.check_for_android_changes.outputs.android_changed == 'true'
needs: check_for_relevant_changes
if: needs.check_for_relevant_changes.outputs.android_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# token: ${{ env.GH_TOKEN }}
token: ${{ env.GH_TOKEN }}

- name: ☕️ Set up Adopt JDK 17
uses: actions/setup-java@v3
Expand All @@ -81,5 +116,48 @@ jobs:
distribution: "adopt"

- name: 🚧 Build Asgardeo Android SDK
working-directory: .github/workflows/scripts/android
working-directory: ${{ env.ANDROID_SCRIPT_DIR }}
run: bash ./android_sdk_build.sh

documentation-builder:
name: 📑 🚧 Documentation Builder
needs: check_for_relevant_changes
if: needs.check_for_relevant_changes.outputs.documentation_changed == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [lts/*]
steps:
- name: ⬇️ Checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ env.GH_TOKEN }}

- name: 🟢 Setup node
id: setup-node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: 🧩 Install Dependencies
id: install-dependencies
working-directory: ${{ env.DOC_DIR }}
run: npm ci

- name: 🏗️ Build with VitePress
id: build
working-directory: ${{ env.DOC_DIR }}
run: |
npm run docs:build
- name: ☕️ Set up Adopt JDK 17 (For Android SDK API Docs Generation)
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"

- name: 🤖 Generate Android SDK API Docs
working-directory: ${{ env.DOCS_SCRIPT_DIR }}/android
run: bash ./dokka_build.sh
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
BOT_EMAIL: ${{ secrets.RELEASE_BOT_EMAIL }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
ANDROID_SCRIPT_DIR: .github/workflows/scripts/android

jobs:
release:
Expand Down Expand Up @@ -73,6 +74,6 @@ jobs:
distribution: "adopt"

- name: 🤖 Release Android SDKs
working-directory: .github/workflows/scripts/android
working-directory: ${{ env.ANDROID_SCRIPT_DIR }}
if: ${{ github.event.inputs.sdkType == 'android' }}
run: bash ./android_sdk_release.sh ${{ github.event.inputs.version }} ${{ env.NEXUS_USERNAME }} ${{ env.NEXUS_PASSWORD }} ${{ env.GH_TOKEN }} ${{ github.run_number }} ${{ github.repository }}

0 comments on commit de47796

Please sign in to comment.