|
| 1 | +name: Build LRM images |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'lrm-*' |
| 6 | + workflow_dispatch: |
| 7 | +jobs: |
| 8 | + get-tag: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + version: ${{ steps.extract-lrm-version.outputs.version }} |
| 12 | + steps: |
| 13 | + - name: Extract version from tag |
| 14 | + id: extract-lrm-version |
| 15 | + run: | |
| 16 | + TAG_NAME="${{ github.ref_name }}" |
| 17 | + VERSION=${TAG_NAME#lrm-} |
| 18 | + PATTERN="^([0-9]+\.[0-9]+(\.[0-9]+)?)(-[A-Za-z0-9\.]+)*$" |
| 19 | + if [[ ! "$VERSION" =~ $PATTERN ]]; then |
| 20 | + echo "Invalid version number" |
| 21 | + echo $VERSION |
| 22 | + exit 1 |
| 23 | + fi |
| 24 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 25 | +
|
| 26 | + build-images: |
| 27 | + needs: get-tag |
| 28 | + runs-on: ubuntu-latest |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - name: 'hub-lrm-back' |
| 33 | + context: './web/lrm/server' |
| 34 | + - name: 'hub-lrm-front' |
| 35 | + context: './web/lrm/client' |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v5 |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + - name: Login to Container Registry |
| 43 | + uses: docker/login-action@v3 |
| 44 | + with: |
| 45 | + registry: ghcr.io |
| 46 | + username: ${{ github.actor }} |
| 47 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + - name: Build and push Docker image |
| 49 | + uses: docker/build-push-action@v6 |
| 50 | + with: |
| 51 | + push: true |
| 52 | + platforms: linux/amd64 |
| 53 | + tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ needs.get-tag.outputs.version }} |
| 54 | + context: ${{ matrix.context }} |
| 55 | + |
| 56 | + image-security-scan: |
| 57 | + name: Scan Docker Images |
| 58 | + needs: [get-tag, build-images] |
| 59 | + runs-on: ubuntu-latest |
| 60 | + continue-on-error: true |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + include: |
| 65 | + - name: 'hub-lrm-back' |
| 66 | + folder: './web/lrm/server' |
| 67 | + - name: 'hub-lrm-front' |
| 68 | + folder: './web/lrm/client' |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@v5 |
| 72 | + - name: Login to Container Registry |
| 73 | + uses: docker/login-action@v3 |
| 74 | + with: |
| 75 | + registry: ghcr.io |
| 76 | + username: ${{ github.actor }} |
| 77 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + - name: Scan Dispatcher Docker image |
| 79 | + uses: aquasecurity/trivy-action@0.33.1 |
| 80 | + with: |
| 81 | + image-ref: 'ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ needs.get-tag.outputs.version }}' |
| 82 | + format: 'table' |
| 83 | + severity: 'HIGH,CRITICAL' |
| 84 | + exit-code: '1' |
| 85 | + trivyignores: '${{ matrix.folder }}/.trivyignore' |
0 commit comments