# Copyright (c) 2023, 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.

name: Build Open Banking Repository

on:
  # Triggers the workflow on push or pull request events
  pull_request:
    branches:
      - '3.0.0'

jobs:

  Build-repo-check:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 8
        uses: actions/setup-java@v1
        with:
          java-version: 8
      - uses: actions/checkout@v3
      - name: Set up Node 16
        uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: Cache local Maven repository
        uses: actions/cache@v4
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-

      - name: Setup Maven settings.xml
        uses: whelk-io/maven-settings-xml-action@v11
        with:
          mirrors: >
            [
              {
                "id": "wso2-nexus",
                "mirrorOf": "wso2-nexus",
                "url": "http://maven.wso2.org/nexus/content/groups/wso2-public/"
              },
              {
                "id": "wso2.releases",
                "mirrorOf": "wso2.releases",
                "url": "http://maven.wso2.org/nexus/content/repositories/releases/"
              },
              {
                "id": "wso2.snapshots",
                "mirrorOf": "wso2.snapshots",
                "url": "http://maven.wso2.org/nexus/content/repositories/snapshots/"
              },
              {
                "id": "knopflerfish",
                "mirrorOf": "knopflerfish",
                "url": "http://resources.knopflerfish.org/repo/maven2/release"
              }
            ]
      - name: Build with Maven
        run: |
          export MAVEN_OPTS="-Xmx4g -XX:MaxPermSize=512m"
          mvn -B install --file pom.xml
