Skip to content

Commit

Permalink
Merge pull request #440 from bcgov/feature/GetAppVersion
Browse files Browse the repository at this point in the history
Feature/get app version
  • Loading branch information
jianmingtu authored Mar 18, 2024
2 parents d6ab79e + b718d28 commit 034b8bf
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,52 @@ jobs:
# secrets:
# nexus_url: ${{ secrets.NEXUS_URL }}

# app-version disabled since "Error: Process completed with exit code 1.", not sure exit code 1 is because of echo 1 (${version)
# app-version:
# uses: SierraSystems/reusable-workflows/.github/workflows/java-maven-app-version.yml@main
# with:
# working_directory: "src/${{ github.event.inputs.app_name }}"
app-version:
name: Get the app-version from the POM file
runs-on: ubuntu-latest
defaults:
run:
working-directory: "."
outputs:
app-version: ${{ steps.get-app-version.outputs.version }}

steps:
- uses: actions/checkout@v2

- name: Build Vips Client
working-directory: "./src/libs"
run: git submodule update --init

- name: "Set up JDK 17"
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Get Project Version
id: get-app-version
working-directory: "./src"
run: |
_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -P${{ github.event.inputs.app_name }})
echo "version=$_version " >> "$GITHUB_OUTPUT"
echo $_version
build-and-push-image:
needs:
- app-version
uses: SierraSystems/reusable-workflows/.github/workflows/docker-build-and-push-image.yml@main
with:
app_name: ${{ github.event.inputs.app_name }}
working_directory: .
# image_tags: "dev,${{ needs.app-version.outputs.app-version }}"
image_tags: "dev,1"
image_tags: "dev,${{ needs.app-version.outputs.app-version }}"
env: tools
build_args: |-
DPS_SERVICE_NAME=${{ github.event.inputs.app_name }}
Expand All @@ -63,13 +96,12 @@ jobs:

trivy:
needs:
# - app-version
- app-version
- build-and-push-image
uses: SierraSystems/reusable-workflows/.github/workflows/trivy-scan-openshift-image.yml@main
with:
imagestream_name: ${{ github.event.inputs.app_name }}
# image_tag: "${{ needs.app-version.outputs.app-version }}"
image_tag: "latest"
image_tag: "${{ needs.app-version.outputs.app-version }}"
secrets:
openshift_external_repository: "${{ secrets.OPENSHIFT_EXTERNAL_REPOSITORY_SILVER }}"
openshift_namespace: "${{ secrets.OPENSHIFT_LICENSE_PLATE_SILVER }}-tools"
Expand Down

0 comments on commit 034b8bf

Please sign in to comment.