-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (88 loc) · 3.38 KB
/
ImageRdmaTools.yaml
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
name: Image Rdma Tools
env:
IMAGE_NAME: rdma-tools
DOCKERFILE_PATH: rdma-tools/image
GEN_DOCKERFILE_SCRIPT: rdma-tools/image/generateDockerfile.sh
on:
push:
branches:
- 'main'
paths:
- rdma-tools/image/**
pull_request_target:
types:
- opened
- synchronize
- reopened
paths:
# can not use env here
- rdma-tools/image/**
workflow_dispatch:
inputs:
ref:
description: 'compile the image based on the sha or branch of code'
required: true
default: main
permissions: write-all
jobs:
get_info:
runs-on: ubuntu-latest
outputs:
code_sha: ${{ env.code_sha }}
push_image: ${{ env.push_image }}
build_platform: ${{ env.build_platform }}
upload_artifact: ${{ env.upload_artifact }}
image_tag: ${{ env.image_tag }}
image_name: ${{ env.image_name }}
dockerfile_dirctory: ${{ env.dockerfile_dirctory }}
generateDockerfileScript: ${{ env.generateDockerfileScript }}
steps:
- name: get information
run: |
echo '${{ toJSON(github) }}'
echo "image_name=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
echo "build_platform=linux/amd64" >> $GITHUB_ENV
echo "upload_artifact=false" >> $GITHUB_ENV
echo "dockerfile_dirctory=${{ env.DOCKERFILE_PATH }}" >> $GITHUB_ENV
echo "generateDockerfileScript=${{ env.GEN_DOCKERFILE_SCRIPT }}" >> $GITHUB_ENV
if ${{ github.event_name == 'workflow_dispatch' }}; then
echo "call by workflow_dispatch"
echo "code_sha=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
echo "push_image=true" >> $GITHUB_ENV
elif ${{ github.event_name == 'push' }} ; then
echo "call by push tag"
echo "code_sha=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "push_image=true" >> $GITHUB_ENV
else
echo "call by PR"
echo "use sha ${{ github.event.pull_request.head.sha }} , by pr"
echo "code_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "push_image=false" >> $GITHUB_ENV
fi
- name: Checkout Source Code
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ env.code_sha }}
- name: Generate Dockerfile
run: |
set -x
cd ${{ env.DOCKERFILE_PATH }}
chmod +x ./generateDockerfile.sh
source ./generateDockerfile.sh
image_tag=$( git ls-tree --full-tree HEAD -- ${{ env.DOCKERFILE_PATH }} | awk '{ print $3 }' )
[ -n "${image_tag}" ] || { echo "error, failed to get image_tag from commit id"; exit 1 ; }
echo "image_tag=${ENV_BASEIMAGE_CUDA_VERISON}-${image_tag}" >> $GITHUB_ENV
call-workflow:
needs: [get_info]
uses: ./.github/workflows/callBuildImage.yaml
with:
code_sha: ${{ needs.get_info.outputs.code_sha }}
push_image: ${{ needs.get_info.outputs.push_image }}
image_name: ${{ needs.get_info.outputs.image_name }}
dockerfile_dirctory: ${{ needs.get_info.outputs.dockerfile_dirctory }}
build_platform: ${{ needs.get_info.outputs.build_platform }}
upload_artifact: ${{ needs.get_info.outputs.upload_artifact }}
image_tag: ${{ needs.get_info.outputs.image_tag }}
generateDockerfileScript: ${{ needs.get_info.outputs.generateDockerfileScript }}
secrets: inherit