mirror of
https://github.com/spring-cloud/spring-cloud-build.git
synced 2026-09-17 12:49:00 +00:00
95 lines
2.9 KiB
YAML
95 lines
2.9 KiB
YAML
name: Spring Cloud Build Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
# Equivalent to Timer Trigger (H H * * * = once daily)
|
|
schedule:
|
|
- cron: '0 0 * * *' # Runs at midnight UTC daily
|
|
|
|
# Manual trigger to replicate the BRANCH parameter
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: 'Which branch should be built'
|
|
required: true
|
|
default: 'main'
|
|
type: string
|
|
|
|
env:
|
|
BRANCH: ${{ github.event.inputs.branch || github.ref_name }}
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
java-versions: ${{ steps.set-matrix.outputs.versions }}
|
|
steps:
|
|
- name: Determine JDK versions based on branch
|
|
id: set-matrix
|
|
run: |
|
|
BRANCH="${{ env.BRANCH }}"
|
|
# Define JDK versions for each branch
|
|
# Main branch supports all versions
|
|
if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "4.3.x" ]]; then
|
|
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
|
|
if [[ "$BRANCH" == "4.2.x" ]] || [[ "$BRANCH" == "4.1.x" ]]; then
|
|
echo 'versions=["17","21",]' >> $GITHUB_OUTPUT
|
|
if [[ "$BRANCH" == "3.1.x" ]]; then
|
|
echo 'versions=["8","11","17"]' >> $GITHUB_OUTPUT
|
|
# Default: use all versions if branch not specified
|
|
else
|
|
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build:
|
|
needs: setup
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
strategy:
|
|
matrix:
|
|
java-version: ${{ fromJson(needs.setup.outputs.java-versions) }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
ref: ${{ env.BRANCH }}
|
|
clean: true # Equivalent to WipeWorkspace extension
|
|
|
|
- name: Set up JDK ${{ matrix.java-version }}
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ matrix.java-version }}
|
|
distribution: 'temurin' # OpenJDK distribution
|
|
cache: 'maven'
|
|
server-id: repo.spring.io
|
|
server-username: REPO_SPRING_IO_USERNAME
|
|
server-password: REPO_SPRING_IO_PASSWORD
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Stop running Docker containers
|
|
continue-on-error: true
|
|
run: |
|
|
#!/bin/bash
|
|
if command -v timeout &> /dev/null; then
|
|
timeout 10s docker ps -a -q | xargs -n 1 -P 8 -I {} docker stop {} || echo "Failed to stop docker... Hopefully you know what you're doing"
|
|
fi
|
|
|
|
- name: Verify Maven installation
|
|
run: ./mvnw --version
|
|
|
|
- name: Build and deploy
|
|
env:
|
|
REPO_SPRING_IO_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
|
REPO_SPRING_IO_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
|
run: ./mvnw clean deploy -Pdocs,deploy,spring -B -U
|
|
|