docs(quick-260405-qk2): SSH密钥体系改造 #30
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 Push Images | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_call: | |
| inputs: | |
| version: | |
| description: "Semantic version (e.g. 1.2.3) — passed by release workflow" | |
| required: false | |
| type: string | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - image: control-plane | |
| dockerfile: deploy/docker/control-plane/Dockerfile | |
| context: . | |
| - image: admin | |
| dockerfile: deploy/docker/admin/Dockerfile | |
| context: . | |
| - image: managed-user | |
| dockerfile: deploy/docker/managed-user/Dockerfile | |
| context: . | |
| - image: sing-box-gateway | |
| dockerfile: deploy/docker/sing-box-gateway/Dockerfile | |
| context: . | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare image prefix (lowercase) | |
| run: echo "IMAGE_PREFIX=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/cloud-cli-proxy" >> "$GITHUB_ENV" | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_PREFIX }}/${{ matrix.image }} | |
| tags: | | |
| type=sha,prefix= | |
| type=semver,pattern={{version}},value=${{ inputs.version }},enable=${{ inputs.version != '' }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ inputs.version }},enable=${{ inputs.version != '' }} | |
| type=semver,pattern={{major}},value=${{ inputs.version }},enable=${{ inputs.version != '' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable=${{ inputs.version != '' || github.ref_name == github.event.repository.default_branch }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ matrix.context }} | |
| file: ${{ matrix.dockerfile }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: | | |
| type=gha,scope=${{ matrix.image }} | |
| type=registry,ref=${{ env.IMAGE_PREFIX }}/${{ matrix.image }}:buildcache | |
| cache-to: | | |
| type=gha,scope=${{ matrix.image }},mode=max | |
| type=registry,ref=${{ env.IMAGE_PREFIX }}/${{ matrix.image }}:buildcache,mode=max |