chore: migrate CI from GitHub Actions to Gitea Actions
Replace GitHub Actions workflow with Gitea Actions, and switch container registry from GHCR to Docker Hub.
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
env:
|
||||
APP_NAME: delta-force-guide-server
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
# ================================================================
|
||||
# Single Job: Build, Upload JAR to Release, and Push to GHCR
|
||||
# ================================================================
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21 (Corretto)
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: corretto
|
||||
cache: gradle
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
# 使用 Release Tag 做为 Gradle 属性传入
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew bootJar -x test -PartefactVersion="${{ github.event.release.tag_name }}"
|
||||
|
||||
- name: Resolve JAR file path
|
||||
id: jar
|
||||
run: |
|
||||
JAR_PATH=$(find build/libs -name '*.jar' | head -1)
|
||||
echo "file=$JAR_PATH" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# 上传 JAR 包到 GitHub Release 中
|
||||
- name: Upload JAR to GitHub Release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: ${{ steps.jar.outputs.file }}
|
||||
asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.jar
|
||||
tag: ${{ github.event.release.tag_name }}
|
||||
overwrite: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 登录到 GitHub Container Registry (GHCR)
|
||||
- name: Log in to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# 镜像打标签准备
|
||||
- name: Generate image tags
|
||||
id: meta
|
||||
run: |
|
||||
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||
REPO_LC=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "tag_version=ghcr.io/$OWNER_LC/$REPO_LC:${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
|
||||
echo "tag_latest=ghcr.io/$OWNER_LC/$REPO_LC:latest" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# 构建并上传镜像到 GHCR
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.ci
|
||||
build-args: JAR_FILE=${{ steps.jar.outputs.file }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.meta.outputs.tag_version }}
|
||||
${{ steps.meta.outputs.tag_latest }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Reference in New Issue
Block a user