Skip to content

feat: datagsm api 사용 #968

feat: datagsm api 사용

feat: datagsm api 사용 #968

Workflow file for this run

# ─────────────────────────────────────────────────────────────────
# CI Workflow — Flooding-Server-V2
# Triggers : push (all branches), PR to master/develop
# Secrets : HARBOR_HOST, HARBOR_USERNAME, HARBOR_PASSWORD,
# SLACK_WEBHOOK_URL
# ─────────────────────────────────────────────────────────────────
name: CI
on:
push:
branches: ['**']
pull_request:
branches: [master, develop]
env:
JAVA_VERSION: '24'
HARBOR_PROJECT: flooding
IMAGE_NAME: flooding-server-v2
jobs:
# ── 1. Test ──────────────────────────────────────────────────
test:
name: Test
runs-on: [self-hosted, flooding]
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test --no-daemon
continue-on-error: true
- name: Upload test report
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report
path: build/reports/tests/
# ── 2. Build → Push ──────────────────────────────────────────
build:
name: Build & Push
runs-on: [self-hosted, flooding]
needs: test
if: always()
outputs:
image_tag: ${{ steps.meta.outputs.tag }}
image_full: ${{ steps.meta.outputs.full }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build JAR
run: ./gradlew build -x test --no-daemon
- name: Compute image tag
id: meta
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
BRANCH=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
TAG="${BRANCH}-${SHORT_SHA}"
FULL="${{ secrets.HARBOR_HOST }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}:${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "full=${FULL}" >> $GITHUB_OUTPUT
- name: Build image (nerdctl)
run: |
sudo nerdctl --address /run/containerd/containerd.sock build \
--insecure-registry \
-t "${{ steps.meta.outputs.full }}" \
.
- name: Push to Harbor (nerdctl)
if: github.ref_name == 'master' || github.ref_name == 'develop'
run: |
echo "${{ secrets.HARBOR_PASSWORD }}" | \
sudo nerdctl --address /run/containerd/containerd.sock login \
--insecure-registry \
--username "${{ secrets.HARBOR_USERNAME }}" \
--password-stdin \
"${{ secrets.HARBOR_HOST }}"
sudo nerdctl --address /run/containerd/containerd.sock push \
--insecure-registry \
"${{ steps.meta.outputs.full }}"
- name: Cleanup local images
if: always()
run: |
sudo nerdctl --address /run/containerd/containerd.sock rmi "${{ steps.meta.outputs.full }}" --force 2>/dev/null || true
sudo nerdctl --address /run/containerd/containerd.sock image prune -f 2>/dev/null || true
# ── 3. Trigger CD (master → prod, develop → dev) ─────────────
trigger-cd:
name: Trigger CD
needs: build
if: github.ref_name == 'master' || github.ref_name == 'develop'
uses: ./.github/workflows/cd.yml
with:
image_tag: ${{ needs.build.outputs.image_tag }}
environment: ${{ github.ref_name == 'master' && 'prod' || 'dev' }}
secrets: inherit
# ── 4. Discord notification ───────────────────────────────────
notify:
name: Discord Notify
runs-on: [self-hosted, flooding]
needs: [test, build, trigger-cd]
if: always()
steps:
- name: Sanitize commit message
id: msg
run: |
MSG=$(echo "${{ github.event.head_commit.message }}" | head -1)
echo "first_line=${MSG}" >> $GITHUB_OUTPUT
- name: Install jq
run: which jq || sudo apt-get install -y jq
- name: Send Discord notification
run: |
STATUS="${{ (needs.build.result == 'success') && '✅ SUCCESS' || '❌ FAILED' }}"
COLOR="${{ (needs.build.result == 'success') && '5763719' || '15548997' }}"
COMMIT_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
PAYLOAD=$(jq -n \
--arg status "$STATUS" \
--arg branch "${{ github.ref_name }}" \
--arg commit "$COMMIT_SHORT" \
--arg message "${{ steps.msg.outputs.first_line }}" \
--argjson color "$COLOR" \
'{
allowed_mentions: {roles: ["1445206322730504253"]},
embeds: [{
title: "[CI/CD] Flooding-Server-V2",
color: $color,
fields: [
{name: "Status", value: $status, inline: true},
{name: "Branch", value: $branch, inline: true},
{name: "Commit", value: $commit, inline: true},
{name: "Message", value: $message, inline: false}
]
}]
}')
curl -fsSL -X POST "${{ secrets.DISCORD_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"