|
| 1 | +name: 'image' |
| 2 | +# This is a docker build check and publish job: |
| 3 | +# 1. PR Triggered docker image build check |
| 4 | +# - is for image build check |
| 5 | +# - Enable on main/*-dev branch |
| 6 | +# - push: ${{ github.event_name != 'pull_request' }} ==> false |
| 7 | +# 2. branches push trigger image publish |
| 8 | +# - is for branch/dev/nightly image |
| 9 | +# - commits are merge into main/*-dev ==> vllm-ascend:main / vllm-ascend:*-dev |
| 10 | +# 3. tags push trigger image publish |
| 11 | +# - is for final release image |
| 12 | +# - Publish when tag with v* (pep440 version) ===> vllm-ascend:v1.2.3|latest / vllm-ascend:v1.2.3rc1 |
| 13 | +on: |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - 'main' |
| 17 | + - '*-dev' |
| 18 | + paths: |
| 19 | + - '.github/workflows/image.yml' |
| 20 | + - 'Dockerfile' |
| 21 | + - 'vllm_ascend/**' |
| 22 | + push: |
| 23 | + # Publish image when tagging, the Dockerfile in tag will be build as tag image |
| 24 | + branches: |
| 25 | + - 'main' |
| 26 | + - '*-dev' |
| 27 | + tags: |
| 28 | + - 'v*' |
| 29 | + paths: |
| 30 | + - '.github/workflows/image.yml' |
| 31 | + - 'Dockerfile' |
| 32 | + - 'vllm_ascend/**' |
| 33 | +jobs: |
| 34 | + |
| 35 | + build: |
| 36 | + name: vllm-ascend image |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Prepare |
| 43 | + run: | |
| 44 | + REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') |
| 45 | + echo "REPO_OWNER=${REPO_OWNER}" >> "$GITHUB_ENV" |
| 46 | +
|
| 47 | + - name: Print |
| 48 | + run: | |
| 49 | + echo "REPO_OWNER:""${REPO_OWNER}" |
| 50 | +
|
| 51 | + - name: Docker meta |
| 52 | + id: meta |
| 53 | + uses: docker/metadata-action@v5 |
| 54 | + with: |
| 55 | + # TODO(yikun): add more hub image and a note on release policy for container image |
| 56 | + # The REPO_OWNER will be: |
| 57 | + # - `vllm-project` in usptream repo |
| 58 | + # - lowercase github user in your fork repo |
| 59 | + images: | |
| 60 | + ghcr.io/${{ env.REPO_OWNER }}/vllm-ascend |
| 61 | + # Note for test case |
| 62 | + # https://github.com/marketplace/actions/docker-metadata-action#typeref |
| 63 | + # 1. branch job pulish per main/*-dev branch commits |
| 64 | + # 2. main and dev pull_request is build only, so the tag pr-N is fine |
| 65 | + # 3. only pep440 matched tag will be published: |
| 66 | + # - v0.7.1 --> v0.7.1, latest |
| 67 | + # - pre/post/dev: v0.7.1rc1/v0.7.1rc1/v0.7.1rc1.dev1/v0.7.1.post1, no latest |
| 68 | + # which follow the rule from vLLM with prefix v |
| 69 | + # TODO(yikun): the post release might be considered as latest release |
| 70 | + tags: | |
| 71 | + type=ref,event=branch |
| 72 | + type=ref,event=pr |
| 73 | + type=pep440,pattern={{raw}} |
| 74 | +
|
| 75 | + - name: Free up disk space |
| 76 | + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 |
| 77 | + with: |
| 78 | + tool-cache: true |
| 79 | + docker-images: false |
| 80 | + |
| 81 | + - name: Build - Set up QEMU |
| 82 | + uses: docker/setup-qemu-action@v2 |
| 83 | + # TODO(yikun): remove this after https://github.com/docker/setup-qemu-action/issues/198 resolved |
| 84 | + with: |
| 85 | + image: tonistiigi/binfmt:qemu-v7.0.0-28 |
| 86 | + |
| 87 | + - name: Build - Set up Docker Buildx |
| 88 | + uses: docker/setup-buildx-action@v2 |
| 89 | + |
| 90 | + - name: Publish - Login to GitHub Container Registry |
| 91 | + uses: docker/login-action@v2 |
| 92 | + with: |
| 93 | + registry: ghcr.io |
| 94 | + username: ${{ github.actor }} |
| 95 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + |
| 97 | + - name: Build and push |
| 98 | + uses: docker/build-push-action@v6 |
| 99 | + with: |
| 100 | + platforms: linux/amd64,linux/arm64 |
| 101 | + cache-from: type=gha |
| 102 | + cache-to: type=gha,mode=max |
| 103 | + # only trigger when tag, branch/main push |
| 104 | + push: ${{ github.event_name != 'pull_request' }} |
| 105 | + labels: ${{ steps.meta.outputs.labels }} |
| 106 | + tags: ${{ steps.meta.outputs.tags }} |
0 commit comments