mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 16:06:36 +08:00
109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
name: Build and Push Vue or Spring Boot Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'vue-frontend/**'
|
|
- 'vite-frontend/**'
|
|
- 'springboot-backend/**'
|
|
- '.github/workflows/docker-build.yml'
|
|
|
|
jobs:
|
|
build-vite:
|
|
if: contains(github.event.head_commit.message, '[skip vite]') == false
|
|
name: Build & Push Vite Frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Check for Vite changes
|
|
uses: dorny/paths-filter@v2
|
|
id: vite-changes
|
|
with:
|
|
filters: |
|
|
vite:
|
|
- 'vite-frontend/**'
|
|
|
|
- name: Set up Node.js
|
|
if: steps.vite-changes.outputs.vite == 'true'
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Set up Docker Buildx
|
|
if: steps.vite-changes.outputs.vite == 'true'
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Log in to DockerHub
|
|
if: steps.vite-changes.outputs.vite == 'true'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
|
|
- name: Build and push Vite multi-arch image
|
|
if: steps.vite-changes.outputs.vite == 'true'
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64 \
|
|
--push \
|
|
-t bqlpfy/vite-frontend \
|
|
./vite-frontend
|
|
|
|
build-java:
|
|
if: contains(github.event.head_commit.message, '[skip java]') == false
|
|
name: Build & Push Spring Boot Backend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Check for Java changes
|
|
uses: dorny/paths-filter@v2
|
|
id: java-changes
|
|
with:
|
|
filters: |
|
|
java:
|
|
- 'springboot-backend/**'
|
|
|
|
- name: Set up JDK and Maven
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 21
|
|
distribution: 'temurin'
|
|
|
|
- name: Cache Maven dependencies
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.m2
|
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: ${{ runner.os }}-m2
|
|
|
|
- name: Build Java JAR
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
working-directory: ./springboot-backend
|
|
run: mvn clean package -DskipTests
|
|
|
|
- name: Set up Docker Buildx
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Log in to DockerHub
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
|
|
- name: Build and push Java multi-arch image
|
|
if: steps.java-changes.outputs.java == 'true'
|
|
run: |
|
|
docker buildx build \
|
|
--platform linux/amd64 \
|
|
--push \
|
|
-t bqlpfy/springboot-backend \
|
|
./springboot-backend
|