Skip to content

message-gateway-develop-88 #88

message-gateway-develop-88

message-gateway-develop-88 #88

Workflow file for this run

---
name: message-gateway
run-name: message-gateway-${{ github.ref_name }}-${{ github.run_number }}
on:
push:
branches:
- main
- develop
- 'release/*'
pull_request:
branches:
- main
- develop
- 'release/*'
schedule:
- cron: '0 0 * * *'
env:
SHOULD_PUBLISH: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref , 'refs/heads/release') }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
show-progress: false
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '16'
- name: Set up Java Version
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- name: Get Revision and Set Image Tag
run: |
VERSION_TAG=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')
echo "VERSION_TAG=$VERSION_TAG"
IMAGE_TAGS="${VERSION_TAG}.$(date '+%Y.%m.%d').${{ github.run_number }}"
echo "IMAGE_SEMANTIC_HASH=$IMAGE_TAGS"
echo "Tags: $IMAGE_TAGS"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "IMAGE_SEMANTIC_HASH=$IMAGE_TAGS" >> $GITHUB_ENV
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
- name: Configure Gradle caching
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Gradlew build
run: |
./gradlew bootJar --info --build-cache
- name: Build docker-compose
run: |
MESSAGE_GATEWAY_IMAGE_TAGS=${{ env.IMAGE_TAGS }} docker compose -f docker-compose.yml build
- name: Login to Azure registry
uses: docker/[email protected]
if: ${{ env.SHOULD_PUBLISH == 'true'}}
with:
registry: oaftech.azurecr.io
username: ${{ vars.ACR_PULL_USERNAME }}
password: ${{ secrets.ACR_PULL_PASSWORD }}
- name: Push image to registry
if: ${{ env.SHOULD_PUBLISH == 'true'}}
run: |
docker push oaftech.azurecr.io/oneacrefund/message-gateway:${{ env.IMAGE_TAGS }}
- name: Publish configuration package
uses: actions/[email protected]
if: ${{ env.SHOULD_PUBLISH == 'true'}}
with:
name: message-gateway
path: ${{ github.workspace }}/deployment
sonarcloud:
name: Sonar Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
show-progress: false
- name: Set up Java Version
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/[email protected]
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Configure Gradle caching
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Gradlew test
run: |
./gradlew :test --info --build-cache
- name: SonarCloud analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info
- name: Publish Code Coverage Results
uses: actions/[email protected]
with:
name: test-results
path: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml