-
Notifications
You must be signed in to change notification settings - Fork 20
212 lines (192 loc) · 7.78 KB
/
build-and-push-image-ssh.yml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Build and push image with SSH forwarding
on:
workflow_call:
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
CUMLPRIMS_SSH_PRIVATE_DEPLOY_KEY:
required: true
CUGRAPH_OPS_SSH_PRIVATE_DEPLOY_KEY:
required: true
inputs:
file:
type: string
required: true
image:
default: ""
type: string
required: true
from_:
default: ""
type: string
required: false
build:
default: ""
type: string
required: false
devel:
default: ""
type: string
required: false
push:
default: true
type: boolean
required: false
pull:
default: true
type: boolean
required: false
build-args:
default: ""
type: string
required: false
manual-build:
type: boolean
default: false
required: false
node-version:
type: string
required: false
default: "16.15.1"
files-to-diff:
default: ""
type: string
required: false
jobs:
build-and-publish-image:
runs-on: linux-amd64-cpu4
strategy:
fail-fast: true
matrix:
CUDA: ["11.6.2"]
LINUX: ["ubuntu20.04"]
steps:
- name: Dump runner context
shell: bash
run: |
echo "${{ toJSON(runner) }}";
echo "is_gha_runner=${{ !contains(runner.name, 'rapidsai') }}" >> $GITHUB_ENV;
- name: Set up self-hosted runner
if: ${{ env.is_gha_runner != 'true' }}
shell: bash
run: |
sudo apt update && sudo apt install -y --no-install-recommends jq git-lfs openssh-client
sudo sed -ri "s@$HOME@${{ runner.workspace }}@g" /etc/passwd
sudo chown -R $(id -u):$(id -g) "${{ runner.workspace }}"
echo "HOME=${{ runner.workspace }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
fetch-depth: 0
- name: Checkout LFS
shell: bash
run: git lfs checkout
- name: Free up disk space
if: ${{ env.is_gha_runner == 'true' }}
uses: ./.github/actions/free-disk-space
with:
tool_cache: ${{ runner.tool_cache }}
- name: Get last successful main commit sha
id: last_main_commit
if: ${{ ! inputs.manual-build }}
uses: nrwl/last-successful-commit-action@v1
with:
branch: main
workflow_id: "merge.pr.yml"
github_token: "${{ github.token }}"
- name: Check if files changed
id: files_changed
if: ${{ ! inputs.manual-build }}
uses: tj-actions/[email protected]
with:
base_sha: ${{ steps.last_main_commit.outputs.commit_hash }}
files: |
.npmrc
yarn.lock
lerna.json
${{ inputs.file }}
${{ inputs.files-to-diff }}
.github/workflows/merge.pr.yml
.github/workflows/build-and-push-image-ssh.yml
.github/actions/build-and-publish-image-ssh/action.yml
- name: Set environment variables
shell: bash
run: |
NODE="${{ inputs.node-version }}"
PARALLEL_LEVEL="${PARALLEL_LEVEL:-4}"
VERSION="$(cat lerna.json | jq -r '.version')"
image_type="$(echo "${{ inputs.image }}" | cut -d'-' -f1)"
image_name="$(echo "${{ inputs.image }}" | cut -d'-' -f2)"
REPOSITORY="ghcr.io/${{ github.repository }}"
CUDA_VERSION_MAJOR="$(echo "${{ matrix.CUDA }}" | cut -d'.' -f1)"
CUDA_VERSION_MINOR="$(echo "${{ matrix.CUDA }}" | cut -d'.' -f2)"
CUDA_VERSION_PATCH="$(echo "${{ matrix.CUDA }}" | cut -d'.' -f3)"
RAPIDS_VERSION="$(cat package.json | jq -r '.config.rapids_version')"
files_changed="${{ steps.files_changed.outputs.any_changed == 'true' || steps.files_changed.outputs.any_deleted == 'true' }}"
echo "NODE=$NODE" >> $GITHUB_ENV;
echo "VERSION=$VERSION" >> $GITHUB_ENV;
echo "image_type=$image_type" >> $GITHUB_ENV;
echo "image_name=$image_name" >> $GITHUB_ENV;
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV;
echo "files_changed=$files_changed" >> $GITHUB_ENV;
echo "PARALLEL_LEVEL=$PARALLEL_LEVEL" >> $GITHUB_ENV;
echo "RAPIDS_VERSION=$RAPIDS_VERSION" >> $GITHUB_ENV;
echo "CUDA_VERSION_MAJOR=$CUDA_VERSION_MAJOR" >> $GITHUB_ENV;
echo "CUDA_VERSION_MINOR=$CUDA_VERSION_MINOR" >> $GITHUB_ENV;
echo "CUDA_VERSION_PATCH=$CUDA_VERSION_PATCH" >> $GITHUB_ENV;
echo "BUILD_ARGS<<EOF" >> $GITHUB_ENV;
if [[ -n "${{ inputs.build-args }}" ]]; then
echo -e "${{ inputs.build-args }}" >> $GITHUB_ENV;
fi
if [[ "${{ inputs.image }}" == devel-main ]]; then
echo "ARM64_BASE=nvidia/cuda:${{ matrix.CUDA }}-devel-${{ matrix.LINUX }}" >> $GITHUB_ENV;
echo "AMD64_BASE=nvidia/cuda:${{ matrix.CUDA }}-devel-${{ matrix.LINUX }}" >> $GITHUB_ENV;
elif [[ "${{ inputs.image }}" == runtime-base ]]; then
echo "ARM64_BASE=nvidia/cuda:${{ matrix.CUDA }}-base-${{ matrix.LINUX }}" >> $GITHUB_ENV;
echo "AMD64_BASE=nvidia/cuda:${{ matrix.CUDA }}-base-${{ matrix.LINUX }}" >> $GITHUB_ENV;
fi
if [[ -n "${{ inputs.from_ }}" ]]; then
from__type="$(echo "${{ inputs.from_ }}" | cut -d'-' -f1)";
from__name="$(echo "${{ inputs.from_ }}" | cut -d'-' -f2)";
from_image="${REPOSITORY}:${VERSION}-${from__type}-node${NODE}-cuda${CUDA_VERSION_MAJOR}-${{ matrix.LINUX }}-${from__name}";
echo "FROM_IMAGE=${from_image}" >> $GITHUB_ENV;
fi
if [[ -n "${{ inputs.build }}" ]]; then
build_type="$(echo "${{ inputs.build }}" | cut -d'-' -f1)";
build_name="$(echo "${{ inputs.build }}" | cut -d'-' -f2)";
build_image="${REPOSITORY}:${VERSION}-${build_type}-node${NODE}-cuda${CUDA_VERSION_MAJOR}-${{ matrix.LINUX }}-${build_name}";
echo "BUILD_IMAGE=${build_image}" >> $GITHUB_ENV;
fi
if [[ -n "${{ inputs.devel }}" ]]; then
devel_type="$(echo "${{ inputs.devel }}" | cut -d'-' -f1)";
devel_name="$(echo "${{ inputs.devel }}" | cut -d'-' -f2)";
devel_image="${REPOSITORY}:${VERSION}-${devel_type}-node${NODE}-cuda${CUDA_VERSION_MAJOR}-${{ matrix.LINUX }}-${devel_name}";
echo "DEVEL_IMAGE=${devel_image}" >> $GITHUB_ENV;
fi
echo "EOF" >> $GITHUB_ENV;
echo "IMAGE_NAME=${REPOSITORY}:${VERSION}-${image_type}-node${NODE}-cuda${CUDA_VERSION_MAJOR}-${{ matrix.LINUX }}-${image_name}" >> $GITHUB_ENV;
- name: Build and push image
if: ${{ inputs.manual-build || env.files_changed == 'true' }}
uses: ./.github/actions/build-and-publish-image-ssh
with:
home: ${{ env.HOME }}
pull: ${{ inputs.pull }}
push: ${{ inputs.push }}
file: ${{ inputs.file }}
temp: ${{ runner.temp }}
tags: ${{ env.IMAGE_NAME }}
registry-url: ghcr.io
registry-username: ${{ github.actor }}
registry-password: ${{ github.token }}
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
CUMLPRIMS_SSH_PRIVATE_DEPLOY_KEY: "${{ secrets.CUMLPRIMS_SSH_PRIVATE_DEPLOY_KEY }}"
CUGRAPH_OPS_SSH_PRIVATE_DEPLOY_KEY: "${{ secrets.CUGRAPH_OPS_SSH_PRIVATE_DEPLOY_KEY }}"
build-args: |
${{ env.BUILD_ARGS }}
"NODE_VERSION=${{ env.NODE }}"
"LINUX_VERSION=${{ matrix.LINUX }}"
"RAPIDS_VERSION=${{ env.RAPIDS_VERSION }}"