Add additional temp feature flag to hide HF access token field from c… #1487
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: Container image build and tag | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*' | |
| paths-ignore: | |
| - 'LICENSE*' | |
| - '**.gitignore' | |
| - '**.md' | |
| - '**.txt' | |
| - '.github/ISSUE_TEMPLATE/**' | |
| - '.github/dependabot.yml' | |
| - 'docs/**' | |
| env: | |
| IMG_REGISTRY: ghcr.io | |
| IMG_ORG: kubeflow | |
| IMG_REPO: model-registry/server | |
| PUSH_IMAGE: true | |
| DOCKER_USER: ${{ github.actor }} | |
| DOCKER_PWD: ${{ secrets.GITHUB_TOKEN }} | |
| PLATFORMS: linux/arm64,linux/amd64 | |
| permissions: # set contents: read at top-level, per OpenSSF ScoreCard rule TokenPermissionsID | |
| contents: read | |
| jobs: | |
| prepare: | |
| uses: ./.github/workflows/prepare.yml | |
| build-image: | |
| permissions: | |
| actions: read # anchore/sbom-action for syft | |
| contents: write # anchore/sbom-action for syft | |
| packages: write | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| steps: | |
| # Assign context variable for various action contexts (tag, main, CI) | |
| - name: Assigning tag context | |
| if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v') | |
| run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV | |
| - name: Assigning main context | |
| if: github.head_ref == '' && github.ref == 'refs/heads/main' | |
| run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV | |
| # checkout branch | |
| - uses: actions/[email protected] | |
| # Set up QEMU for multi-architecture builds | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| # Set up Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # set image version | |
| - name: Set main-branch environment | |
| if: env.BUILD_CONTEXT == 'main' | |
| run: | | |
| commit_sha=${{ github.event.after }} | |
| tag=main-${commit_sha:0:7} | |
| echo "VERSION=${tag}" >> $GITHUB_ENV | |
| - name: Set tag environment | |
| if: env.BUILD_CONTEXT == 'tag' | |
| run: | | |
| echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
| - name: Build and Push Image | |
| shell: bash | |
| run: ./scripts/build_deploy.sh | |
| - name: Generate SBOM | |
| uses: anchore/sbom-action@v0 | |
| with: | |
| image: "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}:${{ env.VERSION }}" | |
| format: spdx-json # default, but making sure of the format | |
| artifact-name: "model-registry-server-${{ env.VERSION }}-sbom.spdx.json" | |
| output-file: "model-registry-server-${{ env.VERSION }}-sbom.spdx.json" # pin the file to use it later below | |
| - name: Install Cosign | |
| uses: sigstore/cosign-installer@v3 | |
| - name: Attach SBOM to Image | |
| run: | | |
| cosign attach sbom --sbom model-registry-server-${{ env.VERSION }}-sbom.spdx.json "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}:${{ env.VERSION }}" | |
| - name: Tag Latest and Main | |
| if: env.BUILD_CONTEXT == 'main' | |
| shell: bash | |
| env: | |
| IMG: "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}" | |
| run: | | |
| # Create manifest tags for multi-arch images | |
| docker buildx imagetools create -t ${{ env.IMG }}:latest ${{ env.IMG }}:$VERSION | |
| docker buildx imagetools create -t ${{ env.IMG }}:main ${{ env.IMG }}:$VERSION |