Skip to content

Commit e22bdb5

Browse files
authored
Use shareable calculate-docker-image GHA (#4399)
Add a step in Linux job to calculate and build Docker image if needed. This is similar to how PyTorch CI rebuilds its Docker images atm. ### Testing pytorch/pytorch#105372, PyTorch Lint job uses Linux jobs.
1 parent f4fb3e6 commit e22bdb5

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/linux_job.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ on:
4747
description: Identifies the Docker image by name.
4848
default: "pytorch/conda-builder"
4949
type: string
50+
docker-build-dir:
51+
description: |
52+
The directory containing the build.sh shell script to build the docker image.
53+
The script parameters can be passed to docker build similar to how it is used
54+
in PyTorch, i.e. build.sh "${IMAGE_NAME}" -t "${DOCKER_IMAGE}".
55+
default: ".ci/docker"
56+
type: string
5057
gpu-arch-type:
5158
description: "GPU arch type to use"
5259
default: "cpu"
@@ -138,11 +145,6 @@ jobs:
138145
with:
139146
github-secret: ${{ github.token }}
140147

141-
- name: Pull docker image
142-
uses: ./test-infra/.github/actions/pull-docker-image
143-
with:
144-
docker-image: ${{ env.DOCKER_IMAGE }}
145-
146148
- name: Checkout repository (${{ inputs.repository || github.repository }}@${{ inputs.ref }})
147149
uses: actions/checkout@v3
148150
with:
@@ -152,6 +154,20 @@ jobs:
152154
path: ${{ inputs.repository || github.repository }}
153155
fetch-depth: ${{ inputs.fetch-depth }}
154156

157+
- name: Calculate docker image
158+
id: calculate-docker-image
159+
uses: ./test-infra/.github/actions/calculate-docker-image
160+
with:
161+
docker-image-name: ${{ env.DOCKER_IMAGE }}
162+
docker-build-dir: ${{ inputs.docker-build-dir }}
163+
# This needs to be where the repository is checked out
164+
working-directory: ${{ inputs.repository || github.repository }}
165+
166+
- name: Pull docker image
167+
uses: ./test-infra/.github/actions/pull-docker-image
168+
with:
169+
docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }}
170+
155171
- name: Download artifacts (if any)
156172
uses: actions/download-artifact@v3
157173
if: ${{ inputs.download-artifact != '' }}
@@ -172,6 +188,7 @@ jobs:
172188
working-directory: ${{ inputs.repository }}
173189
env:
174190
ALL_SECRETS: ${{ toJSON(secrets) }}
191+
DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
175192
run: |
176193
set -ex
177194
{

0 commit comments

Comments
 (0)