diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml new file mode 100644 index 000000000..e41e35f5e --- /dev/null +++ b/.github/actions/build/action.yaml @@ -0,0 +1,33 @@ +name: "Create a container build" +description: "This workflow can be used to create a container build from source branches." +inputs: + QUAY_ORG: + description: "Quay organization." + default: "opendatahub" + required: false + IMAGE_REPO: + description: "Quay image repo name." + required: true + IMAGE_TAG: + description: "Quay image tag." + required: true + DOCKERFILE: + description: "Dockerfile." + default: "Dockerfile.redhat" + required: false +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_BRANCH }} + path: build + - name: Build image + shell: bash + working-directory: build + env: + DOCKER_IMAGE_REPO: quay.io/${{ inputs.QUAY_ORG }}/${{ inputs.IMAGE_REPO }} + DOCKER_IMAGE_TAG: ${{ inputs.IMAGE_TAG }} + DOCKER_FILE: ${{ inputs.DOCKERFILE }} + run: | + ./ml_metadata/tools/docker_server/build_docker_image.sh \ No newline at end of file diff --git a/.github/workflows/build-master.yaml b/.github/workflows/build-master.yaml new file mode 100644 index 000000000..252cc1b34 --- /dev/null +++ b/.github/workflows/build-master.yaml @@ -0,0 +1,51 @@ +name: Build MLMD gRPC Server image for Master branch +on: + push: + branches: + - master +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +env: + QUAY_ORG: opendatahub + QUAY_ID: ${{ secrets.QUAY_USERNAME }} + QUAY_TOKEN: ${{ secrets.QUAY_PASSWORD }} + MLMD_IMAGE_REPO: mlmd-grpc-server + MLMD_IMAGE_DOCKERFILE: Dockerfile.redhat + SOURCE_BRANCH: master + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Generate Tag + shell: bash + id: tags + run: | + commit_sha=${{ github.event.after }} + tag=main-${commit_sha:0:7} + echo "tag=${tag}" >> $GITHUB_OUTPUT + - name: Build Image + uses: ./.github/actions/build + with: + QUAY_ORG: ${{ env.QUAY_ORG }} + IMAGE_REPO: ${{ env.MLMD_IMAGE_REPO }} + IMAGE_TAG: ${{ steps.tags.outputs.tag }} + DOCKERFILE: ${{ env.MLMD_IMAGE_DOCKERFILE }} + - name: Login to Quay + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ env.QUAY_ID }} + password: ${{ env.QUAY_TOKEN }} + - name: Push Images + env: + IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.MLMD_IMAGE_REPO }} + MAIN_HASH_TAG: ${{ steps.tags.outputs.tag }} + run: | + docker push ${IMG}:${MAIN_HASH_TAG} + docker tag ${IMG}:${MAIN_HASH_TAG} ${IMG}:latest + docker push ${IMG}:latest + docker tag ${IMG}:${MAIN_HASH_TAG} ${IMG}:main + docker push ${IMG}:main diff --git a/.github/workflows/build-pr.yaml b/.github/workflows/build-pr.yaml new file mode 100644 index 000000000..ccb16ecfe --- /dev/null +++ b/.github/workflows/build-pr.yaml @@ -0,0 +1,40 @@ +name: Container Image Build +on: + pull_request: + paths-ignore: + - 'LICENSE*' + - '**.gitignore' + - '**.md' + - '**.txt' + - '.github/ISSUE_TEMPLATE/**' + - '.github/dependabot.yml' + - 'docs/**' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true +env: + QUAY_ORG: opendatahub + QUAY_ID: ${{ secrets.QUAY_USERNAME }} + QUAY_TOKEN: ${{ secrets.QUAY_PASSWORD }} + MLMD_IMAGE_REPO: mlmd-grpc-server + MLMD_IMAGE_DOCKERFILE: Dockerfile.redhat + SOURCE_BRANCH: ${{ github.ref }} +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Generate Tag + shell: bash + id: tags + run: | + commit_sha=${{ github.event.after }} + tag=main-${commit_sha:0:7} + echo "tag=${tag}" >> $GITHUB_OUTPUT + - name: Build Image + uses: ./.github/actions/build + with: + QUAY_ORG: ${{ env.QUAY_ORG }} + IMAGE_REPO: ${{ env.MLMD_IMAGE_REPO }} + IMAGE_TAG: ${{ steps.tags.outputs.tag }} + DOCKERFILE: ${{ env.MLMD_IMAGE_DOCKERFILE }} \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 90b09f3f0..000000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Container Image Build -on: - pull_request: - paths-ignore: - - 'LICENSE*' - - '**.gitignore' - - '**.md' - - '**.txt' - - '.github/ISSUE_TEMPLATE/**' - - '.github/dependabot.yml' - - 'docs/**' - -jobs: - build-image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Generate Tag - shell: bash - id: tags - run: | - commit_sha=${{ github.event.after }} - tag=main-${commit_sha:0:7} - echo "tag=${tag}" >> $GITHUB_OUTPUT - - name: Build Image - shell: bash - env: - DOCKER_IMAGE_REPO: quay.io/opendatahub/mlmd-grpc-server - DOCKER_IMAGE_TAG: ${{ steps.tags.outputs.tag }} - DOCKER_FILE: Dockerfile.redhat - run: ./ml_metadata/tools/docker_server/build_docker_image.sh \ No newline at end of file