feat: add instance persistent volume events #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
| # This workflow runs for continuous integration (CI) of the project. | |
| name: ci | |
| permissions: | |
| actions: read | |
| contents: read | |
| pull-requests: read | |
| defaults: | |
| run: | |
| shell: bash | |
| on: | |
| workflow_dispatch: { } | |
| push: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| paths-ignore: | |
| - "!.github/workflows/ci.yml" | |
| - "deploy/**" | |
| - "docs/**" | |
| - "pack/**" | |
| - "**.md" | |
| - "**.mdx" | |
| - "**.png" | |
| - "**.jpg" | |
| - "**.jpeg" | |
| - "**.gif" | |
| - "**.webp" | |
| pull_request: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| paths-ignore: | |
| - "!.github/workflows/ci.yml" | |
| - "deploy/**" | |
| - "docs/**" | |
| - "pack/**" | |
| - "**.md" | |
| - "**.mdx" | |
| - "**.png" | |
| - "**.jpg" | |
| - "**.jpeg" | |
| - "**.gif" | |
| - "**.webp" | |
| env: | |
| INPUT_PASSWORD: ${{ secrets.CI_DOCKERHUB_PASSWORD }} | |
| INPUT_REPOSITORY: gpustack-operator | |
| jobs: | |
| expand-matrix: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| matrix: ${{ steps.expand-matrix.outputs.matrix }} | |
| steps: | |
| - name: Set Matrix | |
| id: expand-matrix | |
| run: | | |
| cat <<EOF > matrix.json | |
| [ | |
| { | |
| "runner": "ubuntu-24.04", | |
| "platform": "linux/amd64" | |
| }, | |
| { | |
| "runner": "ubuntu-24.04-arm", | |
| "platform": "linux/arm64" | |
| } | |
| ] | |
| EOF | |
| MATRIX="$(jq -cr . matrix.json)" | |
| echo "matrix=${MATRIX}" >>"$GITHUB_OUTPUT" | |
| echo "DEBUG: matrix=${MATRIX}" | |
| pack: | |
| timeout-minutes: 360 | |
| needs: | |
| - expand-matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.expand-matrix.outputs.matrix) }} | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Maximize Docker Build Space | |
| uses: gpustack/.github/.github/actions/maximize-docker-build-space@main | |
| with: | |
| deep-clean: true | |
| root-reserve-mb: 20480 | |
| - name: Prepare Env | |
| env: | |
| INPUT_REPOSITORY_OWNER: ${{ github.repository_owner }} | |
| INPUT_PLATFORM: ${{ matrix.platform }} | |
| run: | | |
| INPUT_REPOSITORY_OWNER=$(echo "${INPUT_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') | |
| INPUT_PLATFORM=$(echo "${INPUT_PLATFORM}" | tr '[:upper:]' '[:lower:]' | tr '/' '-') | |
| echo "INPUT_NAMESPACE=${INPUT_REPOSITORY_OWNER}" >> $GITHUB_ENV | |
| echo "INPUT_USERNAME=${INPUT_REPOSITORY_OWNER}" >> $GITHUB_ENV | |
| echo "INPUT_PLATFORM=${INPUT_PLATFORM}" >> $GITHUB_ENV | |
| echo "DEBUG: INPUT_NAMESPACE=${INPUT_NAMESPACE}" | |
| echo "DEBUG: INPUT_USERNAME=${INPUT_USERNAME}" | |
| echo "DEBUG: INPUT_PLATFORM=${INPUT_PLATFORM}" | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: false | |
| - name: Setup BuildX | |
| id: setup-buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| network=host | |
| env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 | |
| env.BUILDKIT_STEP_LOG_MAX_SPEED=-1 | |
| buildkitd-flags: | | |
| --allow-insecure-entitlement=network.host | |
| --allow-insecure-entitlement=security.insecure | |
| --oci-worker-net=host | |
| --oci-worker-gc-keepstorage=204800 | |
| - name: Setup BuildX Cache | |
| id: setup-buildx-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: |- | |
| ${{ github.workspace }}/.cache | |
| ${{ github.workspace }}/.sbin | |
| key: ci-${{ matrix.platform }}-${{ hashFiles('go.sum') }} | |
| - name: Restore BuildX Cache | |
| uses: reproducible-containers/buildkit-cache-dance@v3 | |
| with: | |
| builder: ${{ steps.setup-buildx.outputs.name }} | |
| cache-dir: ${{ github.workspace }}/.cache | |
| dockerfile: ${{ github.workspace }}/pack/${{ env.INPUT_REPOSITORY }}/Dockerfile | |
| skip-extraction: ${{ steps.setup-buildx-cache.outputs.cache-hit }} | |
| - name: Login DockerHub | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.INPUT_USERNAME }} | |
| password: ${{ env.INPUT_PASSWORD }} | |
| - name: Get Metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| # NB(thxCode): Don't forget to update the Get Metadata step in the manifest job if you change the tags format here. | |
| with: | |
| images: "${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}" | |
| tags: | | |
| type=ref,event=pr | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=sha,prefix=dev-,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=ref,event=branch,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=sha,prefix={{branch}}-,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=pep440,pattern={{raw}} | |
| type=pep440,pattern=v{{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| suffix=-${{ env.INPUT_PLATFORM }} | |
| - name: Get Build Cache Ref | |
| run: | | |
| # | |
| # Use different cache ref for different branches. | |
| # | |
| # Examples: | |
| # CACHE_FROM_REF | |
| # - vX.Y.Z -> "${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${VERSION|DEFAULT_BRANCH}" | |
| # - PR/PUSH to branch -> "${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${BRANCH|DEFUALT_BRANCH}" | |
| # CACHE_TO_REF | |
| # - vX.Y.Z -> "${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${VERSION}" | |
| # - PUSH to branch -> "${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${BRANCH}" | |
| # | |
| # Stories: | |
| # CACHE_FROM_REF | |
| # - Release tag v0.7.0rc1 -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7, if not found, fallback to ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - Release tag v0.7.0 -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7 | |
| # - PR to "main" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - PR to "v0.7-dev" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7, if not found, fallback to ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - Push to "main" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - Push to "v0.7-dev" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7, if not found, fallback to ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # CACHE_TO_REF | |
| # - Release tag v0.7.0rc1 -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7 | |
| # - Release tag v0.7.0 -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7 | |
| # - PR to "main" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - PR to "v0.7-dev" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7 | |
| # - Push to "main" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-dev | |
| # - Push to "v0.7-dev" branch -> ${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-v0.7 | |
| # | |
| DEFAULT_BRANCH="dev" | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| REF="${GITHUB_REF#refs/tags/}" | |
| IFS="." read -r VERSION_MAJOR VERSION_MINOR VERSION_PATCH <<< "${REF}" | |
| VERSION="${VERSION_MAJOR}.${VERSION_MINOR}" | |
| CACHE_FROM_REF="${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${VERSION}-${INPUT_PLATFORM}" | |
| CACHE_TO_REF="${CACHE_FROM_REF}" | |
| else | |
| REF="${GITHUB_BASE_REF:-${GITHUB_REF}}" | |
| BRANCH="${REF#refs/heads/}" | |
| BRANCH="${BRANCH%-dev}" | |
| CACHE_FROM_REF="${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${BRANCH}-${INPUT_PLATFORM}" | |
| CACHE_TO_REF="${CACHE_FROM_REF}" | |
| fi | |
| if ! docker manifest inspect "${CACHE_FROM_REF}" >/dev/null 2>&1; then | |
| CACHE_FROM_REF="${INPUT_NAMESPACE}/build-cache:${INPUT_REPOSITORY}-${DEFAULT_BRANCH}-${INPUT_PLATFORM}" | |
| fi | |
| echo "CACHE_FROM_REF=${CACHE_FROM_REF}" >> $GITHUB_ENV | |
| echo "CACHE_TO_REF=${CACHE_TO_REF}" >> $GITHUB_ENV | |
| echo "DEBUG: GITHUB_BASE_REF=${GITHUB_BASE_REF}" | |
| echo "DEBUG: GITHUB_REF=${GITHUB_REF}" | |
| echo "DEBUG: CACHE_FROM_REF=${CACHE_FROM_REF}" | |
| echo "DEBUG: CACHE_TO_REF=${CACHE_TO_REF}" | |
| - name: Package | |
| uses: docker/build-push-action@v6 | |
| with: | |
| allow: | | |
| network.host | |
| security.insecure | |
| ulimit: | | |
| nofile=65536:65536 | |
| shm-size: "16G" | |
| provenance: false | |
| sbom: false | |
| push: ${{ github.event_name != 'pull_request' }} | |
| file: ${{ github.workspace }}/pack/${{ env.INPUT_REPOSITORY }}/Dockerfile | |
| context: ${{ github.workspace }} | |
| platforms: ${{ matrix.platform }} | |
| tags: | | |
| ${{ steps.metadata.outputs.tags }} | |
| labels: | | |
| ${{ steps.metadata.outputs.labels }} | |
| cache-from: | | |
| type=registry,ref=${{ env.CACHE_FROM_REF }} | |
| cache-to: | | |
| ${{ github.event_name != 'pull_request' && format('type=registry,mode=max,compression=gzip,ref={0},ignore-error=true', env.CACHE_TO_REF) || '' }} | |
| manifest: | |
| if: ${{ github.event_name != 'pull_request' }} | |
| needs: | |
| - expand-matrix | |
| - pack | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Prepare Env | |
| env: | |
| INPUT_REPOSITORY_OWNER: ${{ github.repository_owner }} | |
| run: | | |
| INPUT_REPOSITORY_OWNER=$(echo "${INPUT_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') | |
| echo "INPUT_NAMESPACE=${INPUT_REPOSITORY_OWNER}" >> $GITHUB_ENV | |
| echo "INPUT_USERNAME=${INPUT_REPOSITORY_OWNER}" >> $GITHUB_ENV | |
| echo "DEBUG: INPUT_NAMESPACE=${INPUT_NAMESPACE}" | |
| echo "DEBUG: INPUT_USERNAME=${INPUT_USERNAME}" | |
| - name: Login DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.INPUT_USERNAME }} | |
| password: ${{ env.INPUT_PASSWORD }} | |
| - name: Get Metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| # NB(thxCode): Don't forget to update the Get Metadata step in the pack job if you change the tags format here. | |
| with: | |
| images: "${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}" | |
| tags: | | |
| type=ref,event=pr | |
| type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=sha,prefix=dev-,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=ref,event=branch,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=sha,prefix={{branch}}-,enable=${{ contains(github.ref, 'refs/heads/v') && endsWith(github.ref, '-dev') }} | |
| type=pep440,pattern={{raw}} | |
| type=pep440,pattern=v{{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| flavor: | | |
| latest=false | |
| - name: Create | |
| env: | |
| INPUT_MATRIX: ${{ needs.expand-matrix.outputs.matrix }} | |
| INPUT_MANIFEST_IMAGES: ${{ toJson(fromJson(steps.metadata.outputs.json).tags) }} | |
| run: | | |
| for MANIFEST_IMAGE in $(echo "${INPUT_MANIFEST_IMAGES}" | jq -r '.[]'); do | |
| docker manifest create --amend "${MANIFEST_IMAGE}" \ | |
| $(echo "${INPUT_MATRIX}" | jq -r --arg tag "${MANIFEST_IMAGE}" '.[].platform | "\($tag)-" + gsub("/"; "-")') | |
| docker manifest inspect "${MANIFEST_IMAGE}" | |
| docker manifest push --purge "${MANIFEST_IMAGE}" | |
| done |