-
Notifications
You must be signed in to change notification settings - Fork 5
167 lines (148 loc) · 5.32 KB
/
pr-builder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# -------------------------------------------------------------------------------------
#
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# --------------------------------------------------------------------------------------
# This workflow will run the build for PRs to check for any build related issues.
name: 👷 PR Builder
on:
pull_request:
types: [ opened, synchronize, labeled ]
branches: [ main ]
paths-ignore:
- "**/LICENSE"
concurrency:
group: pr-builder-${{ github.ref }}
cancel-in-progress: true
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_relevant_changes:
name: 🔄 Check for Relevant Changes
runs-on: ubuntu-latest
outputs:
android_changed: ${{ steps.check_android_changes.outputs.android_changed }}
documentation_changed: ${{ steps.check_documentation_changes.outputs.documentation_changed }}
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ env.GH_TOKEN }}
- 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
with:
token: ${{ env.GH_TOKEN }}
- 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
with:
token: ${{ env.GH_TOKEN }}
- 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_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 }}
- name: ☕️ Set up Adopt JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: 🚧 Build Asgardeo Android SDK
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