-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathbuild-test-and-push-linux-image.yml
More file actions
115 lines (106 loc) · 4.11 KB
/
build-test-and-push-linux-image.yml
File metadata and controls
115 lines (106 loc) · 4.11 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Build and test devcontainer images
on:
workflow_call:
inputs:
os:
type: string
required: true
description: Image OS
repo:
type: string
required: true
description: Image repo
push:
type: string
required: false
default: false
description: Whether to push the image
features:
type: string
required: true
description: JSON list of devcontainer features
container_env:
type: string
required: false
description: JSON map of default envvars to build into the devcontainer
jobs:
build-test-and-upload:
name: ${{ matrix.arch }}
runs-on: ${{ fromJSON(github.repository != 'rapidsai/devcontainers' && '"ubuntu-latest"' || format('"linux-{0}-cpu4"', matrix.arch)) }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
outputs:
hash_amd64: ${{ steps.build.outputs.hash_amd64 }}
hash_arm64: ${{ steps.build.outputs.hash_arm64 }}
base_tag: ${{ steps.json.outputs.base_tag }}
version: ${{ steps.json.outputs.version }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup runner environment
uses: ./.github/actions/setup-runner-env
- id: json
name: Write .devcontainer.json
uses: ./.github/actions/devcontainer-json
with:
os: "${{ inputs.os }}"
features: "${{ inputs.features }}"
container_env: "${{ inputs.container_env }}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.GPUCIBOT_DOCKERHUB_USER || vars.DOCKERHUB_USER }}
password: ${{ secrets.GPUCIBOT_DOCKERHUB_TOKEN || secrets.DOCKERHUB_TOKEN }}
- id: build
name: Build ${{ steps.json.outputs.version }}-${{ steps.json.outputs.base_tag }}-${{ matrix.arch }}
uses: ./.github/actions/build-linux-image
with:
arch: "${{ matrix.arch }}"
repo: "${{ inputs.repo }}"
push: "${{ inputs.push }}"
tag: "${{ steps.json.outputs.version }}-${{ steps.json.outputs.base_tag }}"
push-to-dockerhub:
if: inputs.push == 'true'
name: Push to Docker Hub
needs:
- build-test-and-upload
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.GPUCIBOT_DOCKERHUB_USER || vars.DOCKERHUB_USER }}
password: ${{ secrets.GPUCIBOT_DOCKERHUB_TOKEN || secrets.DOCKERHUB_TOKEN }}
- name: Push multiarch manifest to Docker Hub
shell: bash --noprofile --norc -x -eo pipefail {0}
env:
hash_amd64: "${{ needs.build-test-and-upload.outputs.hash_amd64 }}"
hash_arm64: "${{ needs.build-test-and-upload.outputs.hash_arm64 }}"
repo: "${{ inputs.repo }}"
base_tag: "${{ needs.build-test-and-upload.outputs.base_tag }}"
version: "${{ needs.build-test-and-upload.outputs.version }}"
os: "${{ inputs.os }}"
ref_name: "${{ github.ref_name }}"
run: |
# Ensure repo is lowercase
repo="${repo,,}";
name="${repo}:${version}-${base_tag}";
docker manifest rm "${name}" || true;
sleep 5;
# Create and push the multiarch manifest
docker buildx imagetools create --tag "${name}" "$hash_amd64" "$hash_arm64";
sleep 5;
# Create and push the multiarch manifest without the OS in the tag
docker buildx imagetools create --tag "${name/%-${os//:/}}" "$hash_amd64" "$hash_arm64";
# Create and push the multiarch manifest without RAPIDS version (main branch only)
if [[ "${ref_name}" == "main" ]]; then
sleep 5;
docker buildx imagetools create --tag "${repo}:latest-${base_tag}" "$hash_amd64" "$hash_arm64";
sleep 5;
docker buildx imagetools create --tag "${repo}:latest-${base_tag/%-${os//:/}}" "$hash_amd64" "$hash_arm64";
fi