build #58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| github_access_token: | |
| description: 'github access token' | |
| required: true | |
| type: string | |
| version_number: | |
| description: 'docker hub image version' | |
| required: true | |
| type: string | |
| default: latest | |
| repository_account: | |
| description: 'repository' | |
| required: true | |
| type: string | |
| default: 'isxcode' | |
| branch_number: | |
| description: 'branch' | |
| required: true | |
| type: string | |
| default: 'main' | |
| env: | |
| ADMIN_GITHUB_TOKEN: ${{ inputs.github_access_token }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: | |
| - '18' | |
| steps: | |
| - name: Set timezone to Asia/Shanghai | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Print system info | |
| run: | | |
| echo "Now Date: $(date)" | |
| echo "Home: $(pwd)" | |
| echo "CPU: $(grep -m 1 'model name' /proc/cpuinfo | cut -d: -f2 | xargs)" | |
| echo "Memory: $(free -h | awk '/^Mem:/ {print $2}')" | |
| - name: Checkout spark-yun | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ env.ADMIN_GITHUB_TOKEN }} | |
| repository: ${{ inputs.repository_account }}/spark-yun | |
| ref: ${{ inputs.branch_number }} | |
| - name: Checkout spark-yun-vip | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ env.ADMIN_GITHUB_TOKEN }} | |
| repository: ${{ inputs.repository_account }}/spark-yun-vip | |
| ref: ${{ inputs.branch_number }} | |
| path: "/home/runner/work/spark-yun/spark-yun/spark-yun-vip" | |
| - name: Setup nodejs | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| - name: Print node version | |
| run: node -v | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.0.6 | |
| - name: Print pnpm version | |
| run: pnpm -v | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache pnpm | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('/home/runner/work/spark-yun/spark-yun/spark-yun-frontend/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Setup jdk | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '8' | |
| - name: Print java version | |
| run: java -version | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| with: | |
| gradle-version: '7.6.1' | |
| cache-disabled: true | |
| - name: Print gradle version | |
| run: gradle -version | |
| - name: Cache gradle | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| id: download-cache | |
| with: | |
| path: /home/runner/work/spark-yun/spark-yun/resources/tmp | |
| key: ${{ runner.os }}-file-${{ hashFiles('/home/runner/work/spark-yun/spark-yun/download.sh') }} | |
| - name: Download dependencies | |
| if: steps.download-cache.outputs.cache-hit != 'true' | |
| run: bash /home/runner/work/spark-yun/spark-yun/download.sh | |
| - name: Build with gradle | |
| run: gradle install package | |
| - name: Upload zhiqingyun tar | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: zhiqingyun | |
| path: ./spark-yun-dist/build/distributions/zhiqingyun.tar.gz | |
| - name: Upload zhiqingyun agent tar | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: zhiqingyun-agent | |
| path: ./spark-yun-dist/build/distributions/zhiqingyun-agent.tar.gz | |
| # 上传到docker hub | |
| upload-docker-hub: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Set timezone to Asia/Shanghai | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Checkout spark-yun | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ env.ADMIN_GITHUB_TOKEN }} | |
| repository: ${{ inputs.repository_account }}/spark-yun | |
| ref: ${{ inputs.branch_number }} | |
| - name: Download zhiqingyun tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zhiqingyun | |
| path: ./ | |
| - name: Unzip zhiqingyun tar | |
| run: | | |
| tar -vzxf zhiqingyun.tar.gz -C /tmp | |
| mkdir -p /home/runner/work/spark-yun/spark-yun/resources | |
| mv /tmp/zhiqingyun/resources/jdbc /home/runner/work/spark-yun/spark-yun/resources/ | |
| mkdir -p /home/runner/work/spark-yun/spark-yun/spark-yun-backend/spark-yun-main/build/libs | |
| mv /tmp/zhiqingyun/lib/zhiqingyun.jar /home/runner/work/spark-yun/spark-yun/spark-yun-backend/spark-yun-main/build/libs | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ispong | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and Push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| tags: isxcode/zhiqingyun:${{ inputs.version_number }} | |
| push: true | |
| # 上传到服务器 | |
| upload-server: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Set timezone to Asia/Shanghai | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Download zhiqingyun tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zhiqingyun | |
| path: ./ | |
| - name: Upload package to Ali server | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| password: ${{ secrets.PASSWORD }} | |
| port: 22 | |
| timeout: 3600s | |
| source: "zhiqingyun.tar.gz" | |
| target: /data/file/ | |
| # 上传阿里镜像仓库 | |
| upload-ali-hub: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Set timezone to Asia/Shanghai | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Checkout spark-yun | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ env.ADMIN_GITHUB_TOKEN }} | |
| repository: ${{ inputs.repository_account }}/spark-yun | |
| ref: ${{ inputs.branch_number }} | |
| - name: Download zhiqingyun tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zhiqingyun | |
| path: ./ | |
| - name: Unzip zhiqingyun tar | |
| run: | | |
| tar -vzxf zhiqingyun.tar.gz -C /tmp | |
| mkdir -p /home/runner/work/spark-yun/spark-yun/resources | |
| mv /tmp/zhiqingyun/resources/jdbc /home/runner/work/spark-yun/spark-yun/resources/ | |
| mkdir -p /home/runner/work/spark-yun/spark-yun/spark-yun-backend/spark-yun-main/build/libs | |
| mv /tmp/zhiqingyun/lib/zhiqingyun.jar /home/runner/work/spark-yun/spark-yun/spark-yun-backend/spark-yun-main/build/libs | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Ali Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.cn-shanghai.aliyuncs.com | |
| username: ispong | |
| password: ${{ secrets.ALI_DOCKERHUB_TOKEN }} | |
| - name: Build and Push Amd64 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| tags: registry.cn-shanghai.aliyuncs.com/isxcode/zhiqingyun:${{ inputs.version_number }}-amd64 | |
| push: true | |
| - name: Build and Push Arm64 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/arm64 | |
| tags: registry.cn-shanghai.aliyuncs.com/isxcode/zhiqingyun:${{ inputs.version_number }}-arm64 | |
| push: true | |
| # 上传到代理镜像到阿里云 | |
| upload-agent-ali-hub: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Set timezone to Asia/Shanghai | |
| run: | | |
| sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Download zhiqingyun agent tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zhiqingyun-agent | |
| path: ./ | |
| - name: Create dockerfile | |
| run: | | |
| echo "FROM alpine:latest" > Dockerfile | |
| echo "" >> Dockerfile | |
| echo "COPY zhiqingyun-agent.tar.gz /tmp/zhiqingyun-agent.tar.gz" >> Dockerfile | |
| echo "" >> Dockerfile | |
| echo 'ENTRYPOINT ["tail", "-f", "/dev/null"]' >> Dockerfile | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Ali Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.cn-shanghai.aliyuncs.com | |
| username: ispong | |
| password: ${{ secrets.ALI_DOCKERHUB_TOKEN }} | |
| - name: Build and Push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| tags: registry.cn-shanghai.aliyuncs.com/isxcode/zhiqingyun-agent:${{ inputs.version_number }} | |
| push: true |