Build dispatcher image #124
Workflow file for this run
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: Build dispatcher image | |
| on: | |
| push: | |
| tags: | |
| - 'dispatcher-*' | |
| workflow_dispatch: | |
| inputs: | |
| model_versions: | |
| description: "Liste des versions de modèle séparées par des espaces" | |
| required: true | |
| type: string | |
| jobs: | |
| get-tags: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| dispatcher-version: ${{ steps.extract-dispatcher-version.outputs.version }} | |
| model-versions: ${{ steps.set-model-versions.outputs.versions }} | |
| steps: | |
| - name: Extract version from tag | |
| id: extract-dispatcher-version | |
| run: | | |
| TAG_NAME="${{ github.ref_name }}" | |
| VERSION=${TAG_NAME#dispatcher-} | |
| PATTERN="^([0-9]+\.[0-9]+(\.[0-9]+)?)(-[A-Za-z0-9\.]+)*$" | |
| if [[ ! "$VERSION" =~ $PATTERN ]]; then | |
| echo "Invalid version number" | |
| echo $VERSION | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Set model versions output | |
| id: set-model-versions | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| MODEL_VERSIONS="${{ inputs.model_versions }}" | |
| else | |
| MODEL_VERSIONS="${{ vars.MODEL_VERSIONS }}" | |
| fi | |
| VERSION_JSON_ARRAY=$(echo "$MODEL_VERSIONS" | jq -R 'split(" ")' | jq -c '.') | |
| echo $VERSION_JSON_ARRAY | |
| echo "versions=$VERSION_JSON_ARRAY" >> $GITHUB_OUTPUT | |
| build-dispatcher: | |
| name: Build Dispatcher images | |
| needs: get-tags | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: hub/dispatcher | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| model_version: ${{ fromJson(needs.get-tags.outputs.model-versions) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Grant execute permission for Gradlew | |
| run: chmod +x gradlew | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hardened Images | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: dhi.io | |
| username: ${{ secrets.DHI_USERNAME }} | |
| password: ${{ secrets.DHI_PASSWORD }} | |
| - name: Login to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run tests, build and push Docker image | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DISPATCHER_VERSION: ${{ needs.get-tags.outputs.dispatcher-version }} | |
| MODEL_VERSION: ${{ matrix.model_version }} | |
| run: | | |
| IMAGE_TAG="${DISPATCHER_VERSION}-model-${MODEL_VERSION}" | |
| echo "Building image for $IMAGE_TAG" | |
| ./gradlew jib \ | |
| -Pversion=$DISPATCHER_VERSION \ | |
| -PmodelVersion=$MODEL_VERSION \ | |
| --image ghcr.io/${{ github.repository_owner }}/dispatcher:$IMAGE_TAG | |
| # image-security-scan: | |
| # name: Scan Docker Images | |
| # needs: [get-tags, build-dispatcher] | |
| # runs-on: ubuntu-latest | |
| # continue-on-error: true | |
| # strategy: | |
| # fail-fast: false | |
| # matrix: | |
| # model_version: ${{ fromJson(needs.get-tags.outputs.model-versions) }} | |
| # steps: | |
| # - name: Login to Container Registry | |
| # uses: docker/login-action@v3 | |
| # with: | |
| # registry: ghcr.io | |
| # username: ${{ github.actor }} | |
| # password: ${{ secrets.GITHUB_TOKEN }} | |
| # - name: Scan Dispatcher Docker image | |
| # uses: aquasecurity/trivy-action@0.33.1 | |
| # with: | |
| # image-ref: 'ghcr.io/${{ github.repository_owner }}/dispatcher:${{ needs.get-tags.outputs.dispatcher-version }}-model-${{ matrix.model_version }}' | |
| # format: 'table' | |
| # severity: 'HIGH,CRITICAL' | |
| # exit-code: '1' |