|
| 1 | +name: Presidio Docker Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + REGISTRY_NAME: ghcr.io # SDSC ADD-ON |
| 10 | + USERNAME: ${{ github.repository_owner }} |
| 11 | + TAG: gha${{ github.run_number }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-platform-images: |
| 15 | + name: Build ${{ matrix.image }} (${{ matrix.platform }}) |
| 16 | + runs-on: ${{ matrix.runner }} |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - image: presidio-anonymizer |
| 21 | + platform: linux/amd64 |
| 22 | + runner: ubuntu-latest |
| 23 | + - image: presidio-analyzer |
| 24 | + platform: linux/amd64 |
| 25 | + runner: ubuntu-latest |
| 26 | + # Note: do we want this part of presidio ? Maybe future feature ? |
| 27 | + # - image: presidio-image-redactor |
| 28 | + # platform: linux/amd64 |
| 29 | + # runner: ubuntu-latest |
| 30 | + steps: |
| 31 | + # SDSC ADD-ON |
| 32 | + - name: Get latest Presidio release tag |
| 33 | + id: presidio_release |
| 34 | + run: | |
| 35 | + tag=$(curl -s https://api.github.com/repos/microsoft/presidio/releases/latest | jq -r .tag_name) |
| 36 | + echo "tag=$tag" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + # SDSC ADD-ON |
| 39 | + - name: Checkout Presidio (latest release) |
| 40 | + uses: actions/checkout@v5 |
| 41 | + with: |
| 42 | + repository: microsoft/presidio |
| 43 | + ref: ${{ steps.presidio_release.outputs.tag }} |
| 44 | + |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v3 |
| 47 | + |
| 48 | + # SDSC ADD-ON |
| 49 | + # https://github.com/docker/login-action |
| 50 | + - name: Log in to the Container registry |
| 51 | + uses: docker/login-action@v3.0.0 |
| 52 | + with: |
| 53 | + registry: ${{ env.REGISTRY_NAME }} |
| 54 | + username: ${{ github.actor }} |
| 55 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Build and Push ${{ matrix.image }} for ${{ matrix.platform }} |
| 58 | + run: | |
| 59 | + # Create platform-specific tag |
| 60 | + PLATFORM_TAG=$(echo "${{ matrix.platform }}" | sed 's/\//-/g') |
| 61 | + docker buildx build \ |
| 62 | + --platform ${{ matrix.platform }} \ |
| 63 | + --push \ |
| 64 | + --tag ${{ env.REGISTRY_NAME }}/${{ env.USERNAME }}/${{ matrix.image }}:${{ env.TAG }}-${PLATFORM_TAG} \ |
| 65 | + --cache-from type=registry,ref=${{ env.REGISTRY_NAME }}/${{ env.USERNAME }}/${{ matrix.image }}:latest \ |
| 66 | + --cache-to type=inline \ |
| 67 | + ./${{ matrix.image }} |
| 68 | +
|
| 69 | + create-manifests: |
| 70 | + name: Create Multi-Platform Manifests |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build-platform-images |
| 73 | + steps: |
| 74 | + # SDSC ADD-ON |
| 75 | + # https://github.com/docker/login-action |
| 76 | + - name: Log in to the Container registry |
| 77 | + uses: docker/login-action@v3.0.0 |
| 78 | + with: |
| 79 | + registry: ${{ env.REGISTRY_NAME }} |
| 80 | + username: ${{ github.actor }} |
| 81 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + |
| 83 | + - name: Set up Docker Buildx |
| 84 | + uses: docker/setup-buildx-action@v3 |
| 85 | + |
| 86 | + - name: Create all multi-platform manifests |
| 87 | + run: | |
| 88 | + IMAGES=("presidio-anonymizer" "presidio-analyzer" "presidio-image-redactor") |
| 89 | +
|
| 90 | + for image in "${IMAGES[@]}"; do |
| 91 | + echo "Creating manifest for $image" |
| 92 | + docker buildx imagetools create \ |
| 93 | + --tag ${{ env.REGISTRY_NAME }}/${{ env.USERNAME }}/${image}:${{ env.TAG }} \ |
| 94 | + ${{ env.REGISTRY_NAME }}/${{ env.USERNAME }}/${image}:${{ env.TAG }}-linux-amd64 |
| 95 | + done |
0 commit comments