|
| 1 | +name: Build Docker image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - v1 |
| 10 | + release: |
| 11 | + types: [published] |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: docker-blobcache-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + build_image: |
| 19 | + name: Push Docker image to hub.6scloud.com |
| 20 | + runs-on: ubuntu-latest |
| 21 | + # 保持原有的权限检查,如果不是在该 organization 下运行请移除此行 |
| 22 | + if: github.repository_owner == 'siliconflow' |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Check out the repo |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Login to Docker Registry |
| 29 | + uses: docker/login-action@v3 |
| 30 | + with: |
| 31 | + registry: hub.6scloud.com |
| 32 | + username: ${{ secrets.HUB_6S_CLOUD_USERNAME }} |
| 33 | + password: ${{ secrets.HUB_6S_CLOUD_TOKEN }} |
| 34 | + |
| 35 | + - name: Set up QEMU |
| 36 | + uses: docker/setup-qemu-action@v3 |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Get version |
| 42 | + id: get_version |
| 43 | + run: | |
| 44 | + if [[ "${{ github.event_name }}" == "release" ]]; then |
| 45 | + VERSION=${{ github.ref_name }} |
| 46 | + else |
| 47 | + # 使用前 7 位 commit hash 作为短版本号 |
| 48 | + VERSION=$(echo ${{ github.sha }} | cut -c1-7) |
| 49 | + fi |
| 50 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 51 | +
|
| 52 | + - name: Build and push Docker image |
| 53 | + uses: docker/build-push-action@v5 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + platforms: linux/amd64 |
| 57 | + push: ${{ github.event_name != 'pull_request' }} |
| 58 | + tags: | |
| 59 | + hub.6scloud.com/d1r7umcsfi9c73b4drdg/blobcache:latest |
| 60 | + hub.6scloud.com/d1r7umcsfi9c73b4drdg/blobcache:${{ steps.get_version.outputs.version }} |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
0 commit comments