diff --git a/.github/workflows/build-full-environment.yml b/.github/workflows/build-full-environment.yml index cb350f4d..f29055a6 100644 --- a/.github/workflows/build-full-environment.yml +++ b/.github/workflows/build-full-environment.yml @@ -29,21 +29,22 @@ jobs: uses: ./.github/workflows/mvn-build.yml secrets: inherit with: - PROJECT_NAME: wfprev-war + COMPONENT_NAME: wfprev-war TAG: latest - PROJECT_TYPE: client + COMPONENT_TYPE: client + wfprev-api: uses: ./.github/workflows/mvn-build.yml secrets: inherit with: - PROJECT_NAME: wfprev-api + COMPONENT_NAME: wfprev-api TAG: latest - PROJECT_TYPE: server + COMPONENT_TYPE: server + terragrunt-deploy-dev: uses: ./.github/workflows/terragrunt-deploy.yml - needs: [wfprev-ui] + needs: [wfprev-ui, wfprev-api] with: DEFAULT_APPLICATION_ENVIRONMENT: dev IMAGE_TAG: latest - secrets: inherit diff --git a/.github/workflows/mvn-build.yml b/.github/workflows/mvn-build.yml index 58185430..d671659b 100644 --- a/.github/workflows/mvn-build.yml +++ b/.github/workflows/mvn-build.yml @@ -1,6 +1,6 @@ env: - IMAGE_NAME: "${{ github.repository }}-${{inputs.PROJECT_NAME}}" + IMAGE_NAME: "${{ github.repository }}-${{inputs.COMPONENT_NAME}}" NPMRC: ${{ secrets.NPMRC }} permissions: @@ -11,7 +11,7 @@ permissions: on: workflow_dispatch: inputs: - PROJECT_NAME: + COMPONENT_NAME: type: string description: 'Name of project, as given to the subfolder of /server or /client to build' required: true @@ -19,7 +19,7 @@ on: required: false type: string description: 'Additional tag to add to docker image' - PROJECT_TYPE: + COMPONENT_TYPE: required: true type: choice options: @@ -28,13 +28,13 @@ on: - libs workflow_call: inputs: - PROJECT_NAME: + COMPONENT_NAME: type: string required: true TAG: required: false type: string - PROJECT_TYPE: + COMPONENT_TYPE: required: true type: string @@ -61,31 +61,36 @@ jobs: - name: Add .npmrc file run: echo -e $NPMRC > ~/.npmrc - - name: Build with Maven + - name: Build API with Maven + if: ${{ inputs.COMPONENT_TYPE == 'server' }} run: | export MAVEN_OPTS="-Xmx3072m -XX:MaxMetaspaceSize=512m" export NODE_OPTIONS="--max-old-space-size=4096" - mvn --settings client/mvn_settings/settings.xml --batch-mode --update-snapshots -f client/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package - mvn --settings server/wfprev-api/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/wfprev-api/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package - - - name: Copy files to neccessary folders (frontend) - run: mkdir staging && cp client/wfprev-war/target/*.war staging - - - name: Copy files to neccessary folders (backend) - run: mkdir staging && cp server/wfprev-api/target/*.war staging + mvn --settings ${{ inputs.COMPONENT_TYPE }}/${{ inputs.COMPONENT_NAME }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f ${{ inputs.COMPONENT_TYPE }}/${{ inputs.COMPONENT_NAME }}/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package + + - name: Build UI with Maven + if: ${{ inputs.COMPONENT_TYPE == 'client' }} + run: | + export MAVEN_OPTS="-Xmx3072m -XX:MaxMetaspaceSize=512m" + export NODE_OPTIONS="--max-old-space-size=4096" + mvn --settings ${{ inputs.COMPONENT_TYPE }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f ${{ inputs.COMPONENT_TYPE }}/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package + + + - name: Copy files to neccessary folders + run: mkdir staging && cp ${{ inputs.COMPONENT_TYPE }}/${{ inputs.COMPONENT_NAME }}/target/*.war staging - uses: actions/upload-artifact@v3 with: - name: ${{ inputs.PROJECT_NAME }}-package + name: ${{ inputs.COMPONENT_NAME }}-package path: staging - name: Cache local Maven repository uses: actions/cache@v2 with: path: staging - key: ${{ inputs.PROJECT_NAME }}-maven-${{ hashFiles('**war.xml') }} + key: ${{ inputs.COMPONENT_NAME }}-maven-${{ hashFiles('**war.xml') }} restore-keys: | - ${{ inputs.PROJECT_NAME }}-maven- + ${{ inputs.COMPONENT_NAME }}-maven- docker: needs: build @@ -110,19 +115,11 @@ jobs: # with: # ref: ${{ inputs.BRANCH }} - - name: download artifact (server) - if: ${{ inputs.PROJECT_TYPE == 'server' }} + - name: download artifact uses: actions/download-artifact@v3 with: - name: ${{ inputs.PROJECT_NAME }}-package - path: ${{inputs.PROJECT_TYPE}}/${{inputs.PROJECT_NAME}} - - - name: download artifact (client) - if: ${{ inputs.PROJECT_TYPE == 'client' }} - uses: actions/download-artifact@v3 - with: - name: ${{ inputs.PROJECT_NAME }}-package - path: ${{inputs.PROJECT_TYPE}}/${{inputs.PROJECT_NAME}} + name: ${{ inputs.COMPONENT_NAME }}-package + path: ${{inputs.COMPONENT_TYPE}}/${{inputs.COMPONENT_NAME}} # - name: Update image name if PR number present # if: ${{ github.event.pull_request.number > 0 || inputs.IS_HOTFIX == 'true' }} @@ -153,22 +150,12 @@ jobs: type=ref,event=tag type=raw,value=${{ inputs.TAG }} - - name: Build and push Docker image (backend) - if: ${{ inputs.PROJECT_TYPE == 'server' }} - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + - name: Build and push Docker image + uses: docker/build-push-action@v6 with: - context: ${{inputs.PROJECT_TYPE}}/${{inputs.PROJECT_NAME}} + context: ${{inputs.COMPONENT_TYPE}}/${{inputs.COMPONENT_NAME}} build-args: | - CONTAINER_NAME=${{inputs.PROJECT_NAME}} + CONTAINER_NAME=${{inputs.COMPONENT_NAME}} push: true tags: ${{ steps.meta_pr.outputs.tags }} labels: ${{ steps.meta_pr.outputs.labels }} - - - name: Build and push Docker image (frontend) - if: ${{ inputs.PROJECT_TYPE == 'client' }} - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: ${{inputs.PROJECT_TYPE}}/${{inputs.PROJECT_NAME}} - push: true - tags: ${{ steps.meta_pr.outputs.tags }} - labels: ${{ steps.meta_pr.outputs.labels }}