Skip to content

Commit

Permalink
Merge pull request #146 from bcgov/build-update
Browse files Browse the repository at this point in the history
Build update
  • Loading branch information
vivid-cpreston authored Oct 4, 2024
2 parents fc32322 + 8c71224 commit 546025f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 48 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build-full-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
71 changes: 29 additions & 42 deletions .github/workflows/mvn-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env:

IMAGE_NAME: "${{ github.repository }}-${{inputs.PROJECT_NAME}}"
IMAGE_NAME: "${{ github.repository }}-${{inputs.COMPONENT_NAME}}"
NPMRC: ${{ secrets.NPMRC }}

permissions:
Expand All @@ -11,15 +11,15 @@ 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
TAG:
required: false
type: string
description: 'Additional tag to add to docker image'
PROJECT_TYPE:
COMPONENT_TYPE:
required: true
type: choice
options:
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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' }}
Expand Down Expand Up @@ -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 }}

0 comments on commit 546025f

Please sign in to comment.