| # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created |
| # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path |
|
|
| name: AscentOne Portal Backend - Maven |
|
|
| permissions: |
| actions: read |
| contents: read |
|
|
| on: |
| workflow_dispatch: |
| inputs: |
| command: |
| description: 'Which environment to build' |
| required: true |
| default: 'test' |
| type: choice |
| options: |
| - test |
| - production |
|
|
| jobs: |
| # build-frontend: |
| # uses: ./.github/workflows/AscentOne.yml |
| |
| build: |
| runs-on: ubuntu-latest |
| environment: AscentOne.${{ github.event.inputs.command || 'test' }} |
| |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - name: Set up JDK 11 |
| uses: actions/setup-java@v4 |
| with: |
| java-version: '11' |
| distribution: 'temurin' |
|
|
| # Determine which branch to use in config repo |
| - name: Resolve config repo branch |
| id: config_branch |
| env: |
| BRANCH_NAME: ${{ github.ref_name }} |
| TOKEN: ${{ secrets.ACCESSTOKEN }} |
| run: | |
| if git ls-remote --exit-code --heads \ |
| https://x-access-token:${TOKEN}@github.com/AscentOne-Ltd/AscentOne-cicd-templates.git \ |
| "${BRANCH_NAME}" >/dev/null 2>&1; then |
| |
| echo "ref=${BRANCH_NAME}" >> $GITHUB_OUTPUT |
| echo "Using branch ${BRANCH_NAME}" |
| else |
| echo "ref=main" >> $GITHUB_OUTPUT |
| echo "Branch ${BRANCH_NAME} not found. Using main." |
| fi |
|
|
| |
| # ✅ Pull config repo |
| - name: Checkout config repo |
| uses: actions/checkout@v4 |
| with: |
| repository: AscentOne-Ltd/AscentOne-cicd-templates |
| token: ${{ secrets.CICDACCESSTOKEN }} |
| path: config-repo |
| ref: ${{ steps.config_branch.outputs.ref }} |
| |
| # ✅ Copy configs |
| - name: Copy config files |
| working-directory: AscentOneBackend |
| run: | |
| ENV=${{ github.event.inputs.command || 'test' }} |
| |
| cp ../config-repo/templates/applications/AscentOne//$ENV/application.yml src/main/resources/application.yml |
| cp ../config-repo/templates/applications/AscentOne/$ENV/application-prod.yml src/main/resources/application-prod.yml |
| cp ../config-repo/templates/applications/AscentOne/$ENV/application-int.yml src/main/resources/application-int.yml |
| cp ../config-repo/templates/applications/AscentOne/$ENV/application-dev.yml src/main/resources/application-dev.yml |
| cp ../config-repo/templates/applications/AscentOne/$ENV/logback.xml src/main/resources/logback.xml |
|
| - name: Download frontend artifact |
| uses: dawidd6/action-download-artifact@v3 |
| with: |
| workflow: ascentOneAngularfrontend.yml |
| name: application-ascentOneAngularfrontend-${{ github.event.inputs.command }} |
| path: ascentOneAngularfrontend-new |
|
|
|
|
|
|
|
| - name: Copy malfunction new frontend into backend resource folder |
| run: | |
| rm -rf AscentOneBackend/src/main/webapp/resources/html* |
| mkdir -p AscentOneBackend/src/main/webapp/resources/html |
| cp -r ascentOneAngularfrontend-new/malfunction/. AscentOneBackend/src/main/webapp/resources/html
|
|
| - name: Build with Maven |
| working-directory: AscentOneBackend |
| run: mvn clean package -DskipTests |
|
|
| - name: Upload AscentOneBackend WAR artifact |
| uses: actions/upload-artifact@v4 |
| with: |
| name: AscentOneBackend.war |
| path: AscentOneBackend/target/*.war |