Merge remote-tracking branch 'upstream/main' into sync-main #1
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: Docker Build and Push | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6.0.2 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| run: | | |
| # Get the commit SHA (short version) | |
| COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT | |
| # Get the current timestamp | |
| BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT | |
| # Determine the version and tag based on the event | |
| if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| # For tag pushes, use the tag name as version | |
| VERSION="${{ github.ref_name }}" | |
| TAG="${{ github.ref_name }}" | |
| elif [[ "${{ github.ref_name }}" == "main" ]]; then | |
| # For main branch, use 'latest' | |
| VERSION="main-${COMMIT_SHA}" | |
| TAG="latest" | |
| else | |
| # For PRs and other branches, use 'dev' | |
| VERSION="dev-${COMMIT_SHA}" | |
| TAG="dev" | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker images | |
| uses: docker/bake-action@v7 | |
| with: | |
| files: docker-bake.hcl | |
| targets: default | |
| push: true | |
| env: | |
| REGISTRY: ghcr.io/llm-d-incubation | |
| COMMIT_SHA: ${{ steps.meta.outputs.commit_sha }} | |
| BUILD_DATE: ${{ steps.meta.outputs.build_date }} | |
| VERSION: ${{ steps.meta.outputs.version }} | |
| TAG: ${{ steps.meta.outputs.tag }} | |
| - name: Output image tags | |
| run: | | |
| echo "Images pushed:" | |
| echo " - ghcr.io/llm-d-incubation/batch-gateway-apiserver:${{ steps.meta.outputs.commit_sha }}" | |
| echo " - ghcr.io/llm-d-incubation/batch-gateway-apiserver:${{ steps.meta.outputs.tag }}" | |
| echo " - ghcr.io/llm-d-incubation/batch-gateway-processor:${{ steps.meta.outputs.commit_sha }}" | |
| echo " - ghcr.io/llm-d-incubation/batch-gateway-processor:${{ steps.meta.outputs.tag }}" |