GitHub Actions 提供了一種將 CI/CD 整合到儲存庫中的無縫方式,自動執行各種任務,例如執行測試、建置工件和部署專案。
快照的工作流程
此工作流程在非主分支上觸發或透過工作流程排程事件手動觸發。它包括以下步驟:
- 執行測試:確保您的程式碼通過所有測試。
- 建立 JAR 檔案:編譯您的 Spring Boot 應用程式。
- 建立 Docker 映像並將其推送到 GitHub Docker 註冊表:從產生的工件建立 Docker 映像並將其推送到 GitHub 容器註冊表。
name: Test and Build Snapshot on: push: branches-ignore: - main workflow_dispatch: permissions: contents: read packages: write jobs: maven-verify: if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' cache: maven cache-dependency-path: '**/pom.xml' - name: Verify run: mvn -B clean verify --file pom.xml maven-build: needs: maven-verify runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' cache: maven cache-dependency-path: '**/pom.xml' - name: Build run: mvn -B package --file pom.xml - name: Upload artifact uses: actions/upload-artifact@v4 with: name: app.jar path: target/*.jar docker-build-push: needs: maven-build runs-on: ubuntu-latest env: CURRENT_VERSION: '' steps: - uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v4 with: name: app.jar path: target - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_PAT }} - name: Get Version run: echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - name: Build Docker image uses: docker/build-push-action@v6 with: context: . push: true tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.CURRENT_VERSION }}-${{ github.run_id }}
發布的工作流程
此工作流程在將變更推送到主分支時運行,包括以下步驟:
- 建置發布版本:編譯專案的發布版本。
- 建立 Docker 映像並將其推送到 GitHub Docker 註冊表:建立 Docker 映像並將其推送到 GitHub 容器註冊表。
- 增加 SNAPSHOT 版本:更新 pom.xml 中的版本以用於未來的快照版本。
name: Build Release on: push: branches: - main workflow_dispatch: permissions: contents: read packages: write jobs: maven-build-release: if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' cache: maven cache-dependency-path: '**/pom.xml' - name: Prepare Release Version run: mvn versions:set -DremoveSnapshot - name: Build run: mvn -B clean package --file pom.xml -DskipTests - name: Upload artifact uses: actions/upload-artifact@v4 with: name: app.jar path: target/*.jar docker-build-push: needs: maven-build-release runs-on: ubuntu-latest env: CURRENT_VERSION: '' steps: - uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v4 with: name: app.jar path: target - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_PAT }} - name: Get Version run: | mvn versions:set -DremoveSnapshot echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - name: Build Docker image uses: docker/build-push-action@v6 with: context: . push: true tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.CURRENT_VERSION }}-${{ github.run_id }} increment-version: needs: docker-build-push runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: token: ${{ secrets.GIT_PAT }} - name: Configure Git run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - name: Increment Snapshot Version run: | # Extract current version and increment patch version CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) PATCH=$(echo $CURRENT_VERSION | cut -d. -f3 | cut -d- -f1) NEW_PATCH=$((PATCH + 1)) NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH-SNAPSHOT" # Update version in pom.xml mvn versions:set -DnewVersion=$NEW_VERSION mvn versions:commit # Commit and push the new snapshot version git add pom.xml git commit -m "Increment version to $NEW_VERSION [skip ci]" git push origin $(git rev-parse --abbrev-ref HEAD)
獎金工作流程
CodeQL 工作流程分析您的 Java 程式碼以識別潛在的漏洞和問題。
name: CodeQL on: pull_request: branches: [ "main" ] workflow_dispatch: jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'java' ] steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' cache: maven cache-dependency-path: '**/pom.xml' - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Autobuild uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}"
更新的 Dockerfile
### Build stage FROM eclipse-temurin:21-jre-alpine AS builder # Set the working directory inside the container WORKDIR /tmp # Copy the source code into the container COPY target/*.jar app.jar # Extract the layers RUN java -Djarmode=layertools -jar app.jar extract ### Run stage # Create a minimal production image FROM eclipse-temurin:21-jre-alpine # Set the working directory inside the container WORKDIR /app # Set the working directory inside the container COPY --from=builder /tmp/dependencies/ ./ COPY --from=builder /tmp/snapshot-dependencies/ ./ COPY --from=builder /tmp/spring-boot-loader/ ./ COPY --from=builder /tmp/application/ ./ # Run the binary when the container starts ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
以上是SpringBoot Web 服務 - 部分 Github 操作的詳細內容。更多資訊請關注PHP中文網其他相關文章!

ByteCodeachievesPlatFormIndenceByByByByByByExecutedBoviratualMachine(VM),允許CodetorunonanyplatformwithTheApprepreprepvm.Forexample,Javabytecodecodecodecodecanrunonanydevicewithajvm

Java不能做到100%的平台獨立性,但其平台獨立性通過JVM和字節碼實現,確保代碼在不同平台上運行。具體實現包括:1.編譯成字節碼;2.JVM的解釋執行;3.標準庫的一致性。然而,JVM實現差異、操作系統和硬件差異以及第三方庫的兼容性可能影響其平台獨立性。

Java通過“一次編寫,到處運行”實現平台獨立性,提升代碼可維護性:1.代碼重用性高,減少重複開發;2.維護成本低,只需一處修改;3.團隊協作效率高,方便知識共享。

在新平台上創建JVM面臨的主要挑戰包括硬件兼容性、操作系統兼容性和性能優化。 1.硬件兼容性:需要確保JVM能正確使用新平台的處理器指令集,如RISC-V。 2.操作系統兼容性:JVM需正確調用新平台的系統API,如Linux。 3.性能優化:需進行性能測試和調優,調整垃圾回收策略以適應新平台的內存特性。

javafxeffectife addressemanddressEndressencissencies uningusement insuplatform-agnosticsCenegraphandCsSsStyling.1)itabstractsplactsplatsplatsplatsplatsplatformsthroughascenegraph,確保consistentertrenderingrenderingrenderingacrosswindows,macoswindwind,Macos,MacOs.2)

JVM的工作原理是將Java代碼轉換為機器碼並管理資源。 1)類加載:加載.class文件到內存。 2)運行時數據區:管理內存區域。 3)執行引擎:解釋或編譯執行字節碼。 4)本地方法接口:通過JNI與操作系統交互。

JVM使Java實現跨平台運行。 1)JVM加載、驗證和執行字節碼。 2)JVM的工作包括類加載、字節碼驗證、解釋執行和內存管理。 3)JVM支持高級功能如動態類加載和反射。

Java應用可通過以下步驟在不同操作系統上運行:1)使用File或Paths類處理文件路徑;2)通過System.getenv()設置和獲取環境變量;3)利用Maven或Gradle管理依賴並測試。 Java的跨平台能力依賴於JVM的抽象層,但仍需手動處理某些操作系統特定的功能。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

記事本++7.3.1
好用且免費的程式碼編輯器

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中