-
Notifications
You must be signed in to change notification settings - Fork 164
112 lines (110 loc) · 3.23 KB
/
reusable.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
name: Job Reusable Workflow
on:
workflow_call:
inputs:
name:
required: true
type: string
base_image:
required: true
type: string
device:
required: true
type: string
timeout_minutes:
required: false
type: number
default: 360
dockerfile:
required: true
type: string
exec_command:
required: true
type: string
extra_build_args:
required: false
type: string
extra_run_args:
required: false
type: string
extra_envs:
required: false
type: string
push_command:
required: true
type: string
remote_dev_docker:
required: true
type: string
proxy_config:
required: false
type: string
secrets:
ALIYUN_DOCKER_USERNAME:
required: false
ALIYUN_DOCKER_PASSWORD:
required: false
DOCKER_USERNAME:
required: false
DOCKER_PASSWORD:
required: false
OSS_ENDPOINT:
required: false
OSS_AK:
required: false
OSS_SK:
required: false
jobs:
Job:
if: github.repository == 'alibaba/BladeDISC'
# The type of runner that the job will run on
runs-on: [self-hosted, "${{ inputs.device }}" ]
timeout-minutes: ${{inputs.timeout_minutes}}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a single command using the runners shell
- name: Checkout
uses: actions/[email protected]
- name: Build Docker
run: |
set -e
${{ inputs.proxy_config }}
git submodule sync
git submodule update --depth=1 --init --recursive
docker pull ${{ inputs.base_image }}
docker build -t disc-dev-${{ inputs.name }} \
--build-arg BASEIMAGE=${{ inputs.base_image }} \
${{ inputs.extra_build_args }} \
-f ${{ inputs.dockerfile }} .
- name: Run Job
run: |
set -e
docker run --rm -t --user $(id -u):$(id -g) \
${{ inputs.extra_run_args }} \
-v $HOME/.cache:$HOME/.cache \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v $PWD:/disc \
-e GITHUB_WORKFLOW=$GITHUB_WORKFLOW \
${{ inputs.extra_envs }} \
-e OSS_ENDPOINT=${{ secrets.OSS_ENDPOINT }} \
-e OSS_AK=${{ secrets.OSS_AK }} \
-e OSS_SK=${{ secrets.OSS_SK }} \
-e GH_TOKEN=${{ secrets.BENCHMARK_GH_TOKEN}} \
-w /disc \
disc-dev-${{ inputs.name }} ${{ inputs.exec_command }}
- name: Push Docker Image
env:
ALIYUN_DOCKER_USERNAME: ${{ secrets.ALIYUN_DOCKER_USERNAME }}
ALIYUN_DOCKER_PASSWORD: ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GITHUB_PULL_REQUEST: ${{ github.event.number }}
REMOTE_DEV_DOCKER: ${{ inputs.remote_dev_docker }}
LOCAL_DEV_DOCKER: disc-dev-${{ inputs.name }}
run: |
set -e
if [[ ! -z "${{ inputs.push_command }}" ]]; then
echo "Push docker image"
${{ inputs.push_command }}
fi