From d5a3c52422b5c0e5e164138c2492ecfb34076a49 Mon Sep 17 00:00:00 2001 From: MicroOps Date: Thu, 24 Oct 2024 12:03:50 +0800 Subject: [PATCH] add: workflow build docker image Signed-off-by: MicroOps --- .github/workflows/github-actions-build.yaml | 47 +++++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-actions-build.yaml b/.github/workflows/github-actions-build.yaml index 9049597..72ab9f4 100644 --- a/.github/workflows/github-actions-build.yaml +++ b/.github/workflows/github-actions-build.yaml @@ -1,13 +1,33 @@ name: Build run-name: ${{ github.actor }} is build image πŸš€ -on: [push] +on: [ push ] env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} jobs: + build-ui: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Build + run: make ui + + - name: Upload UI artifact + uses: actions/upload-artifact@v4 + with: + name: ui-${{ github.run_id }} + path: pkg/transport/static + if-no-files-found: error + retention-days: 1 build-image: + needs: + - build-image runs-on: ubuntu-latest permissions: contents: read @@ -15,18 +35,27 @@ jobs: id-token: write strategy: matrix: - OS: [linux, darwin] # ζ“δ½œη³»η»Ÿ - ARCH: [amd64, arm64] # ζžΆζž„ + OS: [ linux, darwin ] # ζ“δ½œη³»η»Ÿ + ARCH: [ amd64, arm64 ] # ζžΆζž„ steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Download UI artifact + uses: actions/download-artifact@v4 + with: + path: pkg/transport/static + pattern: ui-${{ github.run_id }} + - name: Check UI artifact + run: | + if [ ! -d pkg/transport/static ] || [ ! -f "pkg/transport/static/index.html" ] || [ ! -f "pkg/transport/static/logo.svg" ]; then + ls -al pkg/transport/static + echo "UI artifact not found" + exit 1 + fi - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.22' - - uses: actions/setup-node@v4 - with: - node-version: 20 # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign @@ -63,7 +92,7 @@ jobs: wget -O docker/GeoLite2-City.mmdb.gz -c "https://cdn.jsdelivr.net/npm/geolite2-city@1.0.10/GeoLite2-City.mmdb.gz" gunzip docker/GeoLite2-City.mmdb.gz; - name: Build binaries - run: make ui idas + run: make idas env: GOOS: ${{ matrix.OS }} GOARCH: ${{ matrix.ARCH }} @@ -109,7 +138,7 @@ jobs: - name: Upload digest uses: actions/upload-artifact@v4 with: - name: digests-${{ env.PLATFORM_PAIR }} + name: digests-${{ github.run_id }}-${{ matrix.OS }}-${{ matrix.ARCH }} path: /tmp/digests/* if-no-files-found: error retention-days: 1 @@ -122,7 +151,7 @@ jobs: uses: actions/download-artifact@v4 with: path: /tmp/digests - pattern: digests-* + pattern: digests-${{ github.run_id }} merge-multiple: true - name: Set up Docker Buildx