Skip to content

Commit

Permalink
Update build system for notifications-api
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhpalp committed Jul 7, 2023
1 parent 1a43ed9 commit 6108793
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 85 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/deploy-dev-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ jobs:
BRANCH: ${{ vars.PATCH_BRANCH }}
TAG: ${{ vars.HOTFIX_TAG }}

call-mvn-server-patch:
wfnews-api-server-build-patch:
uses: ./.github/workflows/mvn-server-patch.yml
#SMTP_PASSWORD, DV_PASSWORD AND TFC_PROJECT ARE STORED AS SECRET
with:
REGISTRY: ghcr.io
PROJECT_NAME: wfnews-api
BRANCH: ${{ vars.PATCH_BRANCH }}
TAG: ${{ vars.HOTFIX_TAG }}
secrets:
IDIR_AS_EMAIL: ${{ secrets.IDIR_AS_EMAIL }}
IDIR_PASSWORD: ${{ secrets.IDIR_PASSWORD }}

wfone-notifications-api-server-build-patch:
uses: ./.github/workflows/mvn-server-patch.yml
#SMTP_PASSWORD, DV_PASSWORD AND TFC_PROJECT ARE STORED AS SECRET
with:
REGISTRY: ghcr.io
PROJECT_NAME: wfone-notifications-api
BRANCH: ${{ vars.PATCH_BRANCH }}
TAG: ${{ vars.HOTFIX_TAG }}
secrets:
Expand All @@ -41,9 +54,9 @@ jobs:
REGISTRY: ghcr.io
secrets: inherit

terragrunt-deploy-dev:
uses: ./.github/workflows/terragrunt-deploy.yml
needs: [call-mvn-client-patch, call-mvn-server-patch, liquibase-build, apisix-build]
wfnews-terragrunt-deploy-dev:
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
needs: [call-mvn-client-patch, wfnews-api-server-build-patch, liquibase-build, apisix-build]
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand Down Expand Up @@ -109,6 +122,6 @@ jobs:

jmeter-test-dev:
uses: ./.github/workflows/jmeter.yml
needs: [terragrunt-deploy-dev]
needs: [wfnews-terragrunt-deploy-dev]
with:
ENVIRONMENT: dev
21 changes: 16 additions & 5 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@ jobs:
with:
REGISTRY: ghcr.io

call-mvn-server:
wfnews-api-server-build:
if: github.event.pull_request.merged == true
uses: ./.github/workflows/mvn-server.yml
#SMTP_PASSWORD, DV_PASSWORD AND TFC_PROJECT ARE STORED AS SECRET
with:
REGISTRY: ghcr.io
PROJECT_NAME: wfnews-api
secrets:
IDIR_AS_EMAIL: ${{ secrets.IDIR_AS_EMAIL }}
IDIR_PASSWORD: ${{ secrets.IDIR_PASSWORD }}

wfone-notifications-api-server-build:
if: github.event.pull_request.merged == true
uses: ./.github/workflows/mvn-server.yml
with:
REGISTRY: ghcr.io
PROJECT_NAME: wfone-notifications-api
secrets:
IDIR_AS_EMAIL: ${{ secrets.IDIR_AS_EMAIL }}
IDIR_PASSWORD: ${{ secrets.IDIR_PASSWORD }}
Expand All @@ -53,9 +64,9 @@ jobs:
REGISTRY: ghcr.io
secrets: inherit

terragrunt-deploy-dev:
uses: ./.github/workflows/terragrunt-deploy.yml
needs: [call-mvn-client, call-mvn-server, liquibase-build, apisix-build]
wfnews-terragrunt-deploy-dev:
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
needs: [call-mvn-client, wfnews-api-server-build, liquibase-build, apisix-build]
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand Down Expand Up @@ -121,6 +132,6 @@ jobs:

jmeter-test-dev:
uses: ./.github/workflows/jmeter.yml
needs: [terragrunt-deploy-dev]
needs: [wfnews-terragrunt-deploy-dev]
with:
ENVIRONMENT: dev
4 changes: 2 additions & 2 deletions .github/workflows/deploy-prod-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ jobs:
id: get-release-tag


terragrunt-deploy-prod:
wfnews-terragrunt-deploy-prod:
needs: tag-images
uses: ./.github/workflows/terragrunt-deploy.yml
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ jobs:
id: get-release-tag


terragrunt-deploy-prod:
wfnews-terragrunt-deploy-prod:
needs: tag-images
uses: ./.github/workflows/terragrunt-deploy.yml
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-test-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ jobs:
id: get-release-tag


terragrunt-deploy-test:
wfnews-terragrunt-deploy-test:
needs: tag-images
uses: ./.github/workflows/terragrunt-deploy.yml
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ jobs:
id: get-release-tag


terragrunt-deploy-test:
wfnews-terragrunt-deploy-test:
needs: tag-images
uses: ./.github/workflows/terragrunt-deploy.yml
uses: ./.github/workflows/wfnews-terragrunt-deploy.yml
with:
REGISTRY: ghcr.io
#Server and Image name get PR number as appropriate inside deploy step
Expand All @@ -74,7 +74,7 @@ jobs:
#1024 CPU units = 1 vCPU
CLIENT_CPU_UNITS: 2048
CLIENT_MEMORY: 4096
SERVER_CPU_UNITS: 2048
SERVER_CPU_UNITS: 2048
SERVER_MEMORY: 4096
DB_INSTANCE_TYPE: 'db.t3.medium'
INSTANCE_COUNT: 2
Expand Down
35 changes: 16 additions & 19 deletions .github/workflows/mvn-server-patch.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# This is a basic workflow to help you get started with Actions

name: Build Server

env:
IMAGE_NAME: ${{ github.repository }}-server
IMAGE_NAME: "${{ github.repository }}-${{inputs.PROJECT_NAME}}"

# Controls when the workflow will run
on:
on:
workflow_call:
inputs:
REGISTRY:
Expand All @@ -18,20 +15,19 @@ on:
TAG:
required: true
type: string
PROJECT_NAME:
type: string
description: 'Name of project, as given to the subfolder of /server to build'
required: true
secrets:
IDIR_AS_EMAIL:
required: true
IDIR_PASSWORD:
required: true




# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -44,24 +40,24 @@ jobs:
distribution: 'adopt'

- name: Build with Maven
run: mvn --settings server/wfnews-api/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/wfnews-api/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package
run: mvn --settings server/${{ inputs.PROJECT_NAME }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/${{ inputs.PROJECT_NAME }}/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 server/wfnews-api/wfnews-api-rest-endpoints/target/*.war staging
run: mkdir staging && cp server/${{ inputs.PROJECT_NAME }}/${{ inputs.PROJECT_NAME }}-rest-endpoints/target/*.war staging

- uses: actions/upload-artifact@v3
with:
name: Package
name: ${{ inputs.PROJECT_NAME }}-package
path: staging

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: staging
key: ${{ runner.os }}-maven-${{ hashFiles('**war.xml') }}
key: ${{ inputs.PROJECT_NAME }}-maven-${{ hashFiles('**war.xml') }}
restore-keys: |
${{ runner.os }}-maven-
${{ inputs.PROJECT_NAME }}-maven-
docker:
needs: build
runs-on: ubuntu-latest
Expand All @@ -70,13 +66,15 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.BRANCH }}

- name: download artifact
uses: actions/download-artifact@v3
with:
name: Package
name: ${{ inputs.PROJECT_NAME }}-package
path: .

- name: Update image name if PR number present
if: ${{ github.event.pull_request.number > 0 }}
run: echo "IMAGE_NAME = ${{env.IMAGE_NAME}}-hotfix" >> $GITHUB_ENV

- name: Set up QEMU
Expand Down Expand Up @@ -109,5 +107,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta_pr.outputs.tags }}
labels: ${{ steps.meta_pr.outputs.labels }}

labels: ${{ steps.meta_pr.outputs.labels }}
46 changes: 17 additions & 29 deletions .github/workflows/mvn-server.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# This is a basic workflow to help you get started with Actions

name: Build Server

env:
IMAGE_NAME: ${{ github.repository }}-server
IMAGE_NAME: "${{ github.repository }}-${{inputs.PROJECT_NAME}}"

# Controls when the workflow will run
on:
on:
workflow_call:
inputs:
REGISTRY:
type: string
required: true
PROJECT_NAME:
type: string
description: 'Name of project, as given to the subfolder of /server to build'
required: true
secrets:
IDIR_AS_EMAIL:
required: true
IDIR_PASSWORD:
required: true




# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -36,47 +32,40 @@ jobs:
distribution: 'adopt'

- name: Build with Maven
run: mvn --settings server/wfnews-api/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/wfnews-api/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package
run: mvn --settings server/${{ inputs.PROJECT_NAME }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/${{ inputs.PROJECT_NAME }}/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 server/wfnews-api/wfnews-api-rest-endpoints/target/*.war staging
run: mkdir staging && cp server/${{ inputs.PROJECT_NAME }}/${{ inputs.PROJECT_NAME }}-rest-endpoints/target/*.war staging

- uses: actions/upload-artifact@v3
with:
name: Package
name: ${{ inputs.PROJECT_NAME }}-package
path: staging

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: staging
key: ${{ runner.os }}-maven-${{ hashFiles('**war.xml') }}
key: ${{ inputs.PROJECT_NAME }}-maven-${{ hashFiles('**war.xml') }}
restore-keys: |
${{ runner.os }}-maven-
${{ inputs.PROJECT_NAME }}-maven-
docker:
needs: build
runs-on: ubuntu-latest
outputs:
pull_request_number: ${{ steps.pr.outputs.pull_request_number }}

steps:
- uses: actions/checkout@v3

- name: download artifact
uses: actions/download-artifact@v3
with:
name: Package
name: ${{ inputs.PROJECT_NAME }}-package
path: .

- name: Get Pull Request Number
id: pr
run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update image name if PR number present
if: ${{'' != steps.pr.outputs.pull_request_number}}
run: echo "IMAGE_NAME = ${{env.IMAGE_NAME}}-${{ steps.pr.outputs.pull_request_number }}" >> $GITHUB_ENV
if: ${{ github.event.pull_request.number > 0 }}
run: echo "IMAGE_NAME = ${{env.IMAGE_NAME}}-${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -110,5 +99,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta_pr.outputs.tags }}
labels: ${{ steps.meta_pr.outputs.labels }}

labels: ${{ steps.meta_pr.outputs.labels }}
2 changes: 2 additions & 0 deletions .github/workflows/terragrunt-plan.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Used for validation and not in use in codebase

name: Plan using terragrunt

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy using terragrunt
name: Deploy WFNEWS API using terragrunt

on:
workflow_call:
Expand Down
Loading

0 comments on commit 6108793

Please sign in to comment.