Repository navigation
73 lines (66 loc) · 2.37 KB
/
Copy pathdocker-build.yml
File metadata and controls
73 lines (66 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Docker Build
on:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1,4' # 06:00 UTC every Monday and Thursday
push:
branches:
- main
# A fork PR gets no OIDC token to push to ECR, so a PR opts in with the
# ciflow/docker label instead, which pushes this tag from the base repo.
tags:
- ciflow/docker/*
paths:
- .ci/docker/**
- .github/workflows/docker-build.yml
jobs:
docker-build:
# BuildKit runs out of cluster on the OSDC BuildKit pool, so this runner only
# streams the (small) .ci/docker context and waits.
runs-on: mt-l-x86iavx512-8-64
container:
image: ghcr.io/actions/actions-runner:latest
timeout-minutes: 240
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
include:
- docker-image-name: tutorials
env:
DOCKER_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/tutorials/${{ matrix.docker-image-name }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::308535385114:role/arc
aws-region: us-east-1
role-duration-seconds: 18000
# buildx forwards the client's registry auth to the remote builder, so the
# push at the end of build.sh authenticates with what this step writes.
- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v2
with:
registries: "308535385114"
- name: Compute the image tag
id: tag
shell: bash
run: |
set -eux
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
DOCKER_TAG=$(git rev-parse HEAD:.ci/docker)
echo "docker-image=${DOCKER_IMAGE}:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
- name: Build and push to ECR
uses: pytorch/test-infra/.github/actions/docker-build-remote-buildkit@main
with:
command: |
cd .ci/docker
REMOTE_BUILDKIT=1 ./build.sh ${{ matrix.docker-image-name }} \
-t ${{ steps.tag.outputs.docker-image }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true