fix: update Docker tags format in CI/CD and release workflows #16
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 Trivy Scan | ||
|
Check failure on line 1 in .github/workflows/docker-build-and-scan.yaml
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| DOCKER_PATH_CONTEXT: | ||
| required: true | ||
| type: string | ||
| DOCKER_BUILD_DOCKERFILE: | ||
| required: true | ||
| type: string | ||
| DOCKER_TAGS: | ||
| required: true | ||
| type: string | ||
| DOCKER_LOAD_BOOL: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| DOCKER_PUSH_BOOL: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| DOCKER_USERNAME: | ||
| required: true | ||
| type: string | ||
| DOCKER_PLATFORMS: | ||
| required: false | ||
| type: string | ||
| default: 'linux/amd64,linux/arm64' | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| platform: ${{ fromJson(inputs.DOCKER_PLATFORMS) }} | ||
| env: | ||
| DOCKER_PATH_CONTEXT: ${{ inputs.DOCKER_PATH_CONTEXT }} | ||
| DOCKER_BUILD_DOCKERFILE: ${{ inputs.DOCKER_BUILD_DOCKERFILE }} | ||
| DOCKER_TAGS: ${{ inputs.DOCKER_TAGS }} | ||
| DOCKER_USERNAME: ${{ inputs.DOCKER_USERNAME }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: docker/setup-qemu-action@v4 | ||
| - uses: docker/setup-buildx-action@v4 | ||
| - uses: docker/login-action@v4 | ||
| with: | ||
| username: ${{ env.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Build & push per-arch image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: ${{ env.DOCKER_PATH_CONTEXT }} | ||
| file: ${{ env.DOCKER_BUILD_DOCKERFILE }} | ||
| platforms: ${{ matrix.platform }} | ||
| push: true | ||
| tags: docker.io/${{ env.DOCKER_TAGS }}-${{ matrix.platform.replace('/', '-') }} | ||
| - name: Run Trivy vulnerability scanner (per-arch) | ||
| uses: aquasecurity/trivy-action@0.35.0 | ||
| with: | ||
| image-ref: docker.io/${{ env.DOCKER_TAGS }}-${{ matrix.platform }} | ||
| format: 'table' | ||
| exit-code: '1' | ||
| ignore-unfixed: true | ||
| vuln-type: 'os,library' | ||
| severity: 'CRITICAL,HIGH' | ||
| manifest: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| env: | ||
| DOCKER_TAGS: ${{ inputs.DOCKER_TAGS }} | ||
| DOCKER_USERNAME: ${{ inputs.DOCKER_USERNAME }} | ||
| steps: | ||
| - uses: docker/login-action@v4 | ||
| with: | ||
| username: ${{ env.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Create and push multi-arch manifest | ||
| run: | | ||
| docker buildx imagetools create \ | ||
| -t docker.io/${{ env.DOCKER_TAGS }} \ | ||
| docker.io/${{ env.DOCKER_TAGS }}-linux_amd64 \ | ||
| docker.io/${{ env.DOCKER_TAGS }}-linux_arm64 | ||