Build DEV #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build DEV | |
on: | |
push: | |
branches: | |
- dev | |
workflow_dispatch: | |
jobs: | |
build-jar: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
outputs: | |
BUILD_NUMBER: ${{ steps.build-number.outputs.BUILD_NUMBER }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: build-number | |
name: Configuring Build Number | |
run: | | |
echo "BUILD_NUMBER=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT | |
- name: Get current branch name | |
id: get_branch | |
run: echo "CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- name: Test Build Number | |
run: echo "${{ steps.build-number.outputs.BUILD_NUMBER }}" | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3.1.0 | |
- name: Build | |
run: CI=true ./gradlew clean assemble -Pversion=${{ steps.build-number.outputs.BUILD_NUMBER }} | |
- name: Test | |
run: CI=true ./gradlew test | |
- name: Integration Test | |
run: CI=true ./gradlew integrationTest | |
- name: Sonar Scan | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
BRANCH_NAME: ${{ env.CURRENT_BRANCH_NAME }} | |
run: | | |
echo "Branch name $BRANCH_NAME" | |
CI=true ./gradlew sonar --info -Dsonar.branch.name=$BRANCH_NAME | |
- name: Uploading DataGenerator Jars | |
uses: actions/upload-artifact@master | |
with: | |
name: k8s-workshop-data-generator-jar | |
path: module/app/k8s-workshop-data-generator/build/libs | |
build-k8s-workshop-data-generator-image: | |
needs: | |
- build-jar | |
name: Data Generator - Build & Push Docker Image | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Get current branch name | |
id: get_branch | |
run: echo "CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | |
- id: build-number | |
name: Configuring Build Number | |
run: | | |
echo "BUILD_NUMBER=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | |
with: | |
context: module/app/k8s-workshop-data-generator | |
push: true | |
tags: ghcr.io/maeworkshop/k8s-workshop-data-generator:${{ env.CURRENT_BRANCH_NAME }}-${{ needs.build-jar.outputs.BUILD_NUMBER }} |