name: 'Image build lint'
on:
  schedule:
    # Runs at 00:00 UTC+8 every day
    - cron: '0 20 * * *' 
  workflow_dispatch:
  push:
    paths:
      - 'Dockerfile.lint'
      - 'requirements-lint.txt'
      - 'requirements-dev.txt'
      - 'requirements.txt'

# only cancel in-progress runs of the same workflow
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:

  build:
    name: vllm-ascend lint image build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
        persist-credentials: false

    - name: Print
      run: |
        lscpu
    - name: Docker meta
      id: meta
      uses: docker/metadata-action@v5
      with:
        images: |
          quay.io/ascend-ci/vllm-ascend
        tags: lint
        flavor:
          latest=false

    - name: Build - Set up QEMU
      uses: docker/setup-qemu-action@v3

    - name: Build - Set up Docker Buildx
      uses: docker/setup-buildx-action@v3

    - name: Publish - Login to Quay Container Registry
      if: ${{ github.repository_owner == 'vllm-project' }}
      uses: docker/login-action@v3
      with:
        registry: quay.io
        username: ${{ vars.QUAY_CI_USERNAME }}
        password: ${{ secrets.QUAY_CI_PASSWORD }}

    - name: Build and push
      uses: docker/build-push-action@v6
      with:
        # For now, we only build amd64 lint image
        platforms: 'linux/amd64'
        context: .
        file: .github/workflows/dockerfiles/Dockerfile.lint
        push: true
        labels: ${{ steps.meta.outputs.labels }}
        tags: ${{ steps.meta.outputs.tags }}
        provenance: false
