Repository navigation
LSIT-14:补齐 Taro 用户端服务、营销与订单状态恢复 #23
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 and publish Docker | |
| on: | |
| push: | |
| tags: ['*'] | |
| pull_request: | |
| branches: [master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: docker-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| admin: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| working-directory: template/admin | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/cache@v4 | |
| id: admin-cache | |
| with: | |
| path: template/admin/dist | |
| key: admin-node22-pnpm11-v1-${{ hashFiles('template/admin/**') }}-${{ vars.VUE_APP_API_URL }} | |
| - uses: actions/setup-node@v4 | |
| if: steps.admin-cache.outputs.cache-hit != 'true' | |
| with: | |
| node-version: '22.19.0' | |
| - run: npm install --global pnpm@11.22.0 | |
| if: steps.admin-cache.outputs.cache-hit != 'true' | |
| - run: pnpm install --frozen-lockfile | |
| if: steps.admin-cache.outputs.cache-hit != 'true' | |
| - name: Build admin | |
| if: steps.admin-cache.outputs.cache-hit != 'true' | |
| env: | |
| NODE_OPTIONS: --openssl-legacy-provider --max-old-space-size=6144 | |
| VUE_APP_API_URL: ${{ vars.VUE_APP_API_URL }} | |
| run: pnpm build && test -s dist/index.html | |
| - name: Verify admin artifact | |
| run: test -s dist/index.html | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: admin | |
| path: template/admin/dist/ | |
| if-no-files-found: error | |
| retention-days: 7 | |
| image: | |
| needs: admin | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| runner: ubuntu-24.04 | |
| - arch: arm64 | |
| runner: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 45 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: admin | |
| path: template/admin/dist | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| platforms: linux/${{ matrix.arch }} | |
| load: true | |
| tags: ghcr.io/lsiten/crmeb:sha-${{ github.sha }}-${{ matrix.arch }} | |
| build-args: REVISION=${{ github.sha }} | |
| cache-from: type=gha,scope=${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.arch }} | |
| - name: Smoke test image | |
| env: | |
| IMAGE: ghcr.io/lsiten/crmeb:sha-${{ github.sha }}-${{ matrix.arch }} | |
| run: bash docker/smoke-test.sh "$IMAGE" | |
| - uses: docker/login-action@v3 | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push tested image | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| env: | |
| IMAGE: ghcr.io/lsiten/crmeb:sha-${{ github.sha }}-${{ matrix.arch }} | |
| run: docker push "$IMAGE" | |
| publish: | |
| needs: image | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@v5 | |
| id: meta | |
| with: | |
| images: ghcr.io/lsiten/crmeb | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=sha-${{ github.sha }} | |
| type=raw,value=latest | |
| - name: Publish multi-platform version, latest and commit tags | |
| env: | |
| IMAGE: ghcr.io/lsiten/crmeb | |
| IMAGE_TAGS: ${{ steps.meta.outputs.tags }} | |
| run: | | |
| args=() | |
| while IFS= read -r tag; do args+=(--tag "$tag"); done <<< "$IMAGE_TAGS" | |
| docker buildx imagetools create "${args[@]}" \ | |
| "$IMAGE:sha-$GITHUB_SHA-amd64" "$IMAGE:sha-$GITHUB_SHA-arm64" | |
| docker buildx imagetools inspect "$IMAGE:latest" | |
| printf 'Image: `%s:latest`\n\nCommit: `%s`\n' "$IMAGE" "$GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY" |