112 lines
3.1 KiB
YAML
112 lines
3.1 KiB
YAML
# .github/workflows/recommend-ci.yml
|
|
name: Recommend CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
paths:
|
|
- 'recommend/**'
|
|
- 'common/**'
|
|
- 'build.gradle'
|
|
- 'settings.gradle'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'recommend/**'
|
|
- 'common/**'
|
|
- 'build.gradle'
|
|
- 'settings.gradle'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
ACR_NAME: acrdigitalgarage03
|
|
IMAGE_NAME: hiorder/recommend
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- 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
|
|
with:
|
|
gradle-version: '8.13'
|
|
|
|
- name: Cache Gradle packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
|
|
- name: Generate Gradle Wrapper
|
|
run: |
|
|
echo "Generating gradle wrapper..."
|
|
gradle wrapper --gradle-version 8.13
|
|
chmod +x gradlew
|
|
echo "Testing gradle wrapper..."
|
|
./gradlew --version
|
|
|
|
- name: Build recommend module with dependencies
|
|
run: ./gradlew recommend:build -x test
|
|
|
|
- name: Run recommend tests
|
|
run: ./gradlew recommend:test
|
|
|
|
- name: Generate build timestamp
|
|
id: timestamp
|
|
run: echo "BUILD_TIME=$(date +'%y%m%d%H%M')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Azure Container Registry
|
|
uses: azure/docker-login@v1
|
|
with:
|
|
login-server: ${{ env.ACR_NAME }}.azurecr.io
|
|
username: ${{ secrets.ACR_USERNAME }}
|
|
password: ${{ secrets.ACR_PASSWORD }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./recommend/Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ steps.timestamp.outputs.BUILD_TIME }}
|
|
${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:latest
|
|
|
|
- name: Output image tags
|
|
run: |
|
|
echo "🎉 Image pushed successfully!"
|
|
echo "📦 Image: ${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}"
|
|
echo "🏷️ Tags: ${{ steps.timestamp.outputs.BUILD_TIME }}, latest"
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: recommend-test-results
|
|
path: recommend/build/reports/tests/test/
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
if: success()
|
|
with:
|
|
name: recommend-jar
|
|
path: recommend/build/libs/*.jar
|