From 78ee2ee90eed957aec3dc80423b108b16938a8ae Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 26 Jun 2025 02:06:54 +0000 Subject: [PATCH] Fix environment and push env var for docker image builds for binary builds (#156910) Changes WITH_PUSH and the environment check to be ok with giving credentials to push to docker io if its on the main branch, a tag starting with v, or the release branch Credentials for pushing to docker io are in the environment, so without the environment, you can't push to docker io. You also don't do the push unless WITH_PUSH is true binary builds on release branch were failing because they pull from docker io, but the docker build wasn't pushing to docker io because it was either on the release branch (didn't have credentials https://github.com/pytorch/pytorch/actions/runs/15888166271/job/44813180986) or it was on the tag (doesn't have WITH_PUSH) Pull Request resolved: https://github.com/pytorch/pytorch/pull/156910 Approved by: https://github.com/atalman --- .github/workflows/build-almalinux-images.yml | 4 ++-- .github/workflows/build-libtorch-images.yml | 4 ++-- .github/workflows/build-manywheel-images-s390x.yml | 4 ++-- .github/workflows/build-manywheel-images.yml | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-almalinux-images.yml b/.github/workflows/build-almalinux-images.yml index daa5ee23e020..aaf85d7fc806 100644 --- a/.github/workflows/build-almalinux-images.yml +++ b/.github/workflows/build-almalinux-images.yml @@ -23,7 +23,7 @@ on: env: DOCKER_REGISTRY: "docker.io" DOCKER_BUILDKIT: 1 - WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) }} + WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} @@ -32,7 +32,7 @@ concurrency: jobs: build-docker: if: github.repository_owner == 'pytorch' - environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }} + environment: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) && 'docker-build') || '' }} runs-on: linux.9xlarge.ephemeral strategy: matrix: diff --git a/.github/workflows/build-libtorch-images.yml b/.github/workflows/build-libtorch-images.yml index a49673e56382..b2d50efd7d96 100644 --- a/.github/workflows/build-libtorch-images.yml +++ b/.github/workflows/build-libtorch-images.yml @@ -22,7 +22,7 @@ on: env: DOCKER_REGISTRY: "docker.io" DOCKER_BUILDKIT: 1 - WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) }} + WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} @@ -40,7 +40,7 @@ jobs: curr_ref_type: ${{ github.ref_type }} build: - environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }} + environment: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) && 'docker-build') || '' }} needs: get-label-type runs-on: ${{ needs.get-label-type.outputs.label-type }}linux.9xlarge.ephemeral name: libtorch-cxx11-builder:${{ matrix.tag }} diff --git a/.github/workflows/build-manywheel-images-s390x.yml b/.github/workflows/build-manywheel-images-s390x.yml index 0d7d4aafc3c8..c498e169f1aa 100644 --- a/.github/workflows/build-manywheel-images-s390x.yml +++ b/.github/workflows/build-manywheel-images-s390x.yml @@ -12,7 +12,7 @@ on: env: DOCKER_REGISTRY: "docker.io" DOCKER_BUILDKIT: 1 - WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) }} + WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} @@ -21,7 +21,7 @@ concurrency: jobs: build-docker-cpu-s390x: if: github.repository_owner == 'pytorch' - environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }} + environment: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) && 'docker-build') || '' }} runs-on: linux.s390x steps: - name: Checkout PyTorch diff --git a/.github/workflows/build-manywheel-images.yml b/.github/workflows/build-manywheel-images.yml index 19a2303dedd0..e84b84f6158b 100644 --- a/.github/workflows/build-manywheel-images.yml +++ b/.github/workflows/build-manywheel-images.yml @@ -23,8 +23,7 @@ on: env: DOCKER_REGISTRY: "docker.io" DOCKER_BUILDKIT: 1 - WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release')) }} - + WITH_PUSH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true @@ -41,7 +40,7 @@ jobs: curr_ref_type: ${{ github.ref_type }} build: - environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }} + environment: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') || startsWith(github.ref, 'refs/tags/v')) && 'docker-build') || '' }} needs: get-label-type strategy: fail-fast: false