-
Notifications
You must be signed in to change notification settings - Fork 28
143 lines (137 loc) · 4.22 KB
/
build-artifacts.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
name: build-artifacts
on:
issue_comment:
types: [created]
jobs:
check-comment:
runs-on: ubuntu-22.04
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/build-artifacts'}}
outputs:
sha: ${{ steps.sha.outputs.result }}
steps:
- name: Get PR SHA
id: sha
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue;
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: number,
});
return pr.data.head.sha
- uses: actions/checkout@v3
with:
ref: ${{ steps.sha.outputs.result }}
core-docker:
runs-on: ubuntu-22.04
needs: check-comment
strategy:
matrix:
arch: [arm64, amd64]
fail-fast: false
env:
IMAGE_NAME: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}'
TARGETPLATFORM: 'linux/${{ matrix.arch }}'
SERVICE_NAME: core
BASE_IMAGE: dukerobotics/robosub-ros:base
FILE_NAME: '${{ matrix.arch }}-core.tar.gz'
CUDA: ${{ matrix.arch == 'arm64' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.check-comment.outputs.sha }}
- name: Setup environment and build
run: |
./.github/workflows/build.sh
- name: Save image
run: |
docker save ${IMAGE_NAME} | gzip > ${FILE_NAME}
- name: Create artifact from image
uses: actions/upload-artifact@v3
with:
name: core
path: ${{ env.FILE_NAME }}
onboard-docker:
runs-on: ubuntu-22.04
needs: [check-comment, core-docker]
strategy:
matrix:
arch: [arm64, amd64]
fail-fast: false
env:
IMAGE_NAME: 'dukerobotics/robosub-ros:onboard-${{ matrix.arch }}'
TARGETPLATFORM: 'linux/${{ matrix.arch }}'
SERVICE_NAME: onboard
BASE_IMAGE: 'dukerobotics/robosub-ros:core-${{ matrix.arch }}'
CORE_FILE_NAME: '${{ matrix.arch }}-core.tar.gz'
ONBOARD_FILE_NAME: '${{ matrix.arch }}-onboard.tar.gz'
CUDA: ${{ matrix.arch == 'arm64' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.check-comment.outputs.sha }}
- name: Get core image
uses: actions/download-artifact@v3
with:
name: core
path: core_im
- name: Load core image
run: |
docker load < ./core_im/${CORE_FILE_NAME}
rm -rf core_im
- name: Setup environment and build docker image
run: ./.github/workflows/build.sh
- name: Save onboard image
run: |
docker save ${IMAGE_NAME} | gzip > ${ONBOARD_FILE_NAME}
- name: Create artifact from image
uses: actions/upload-artifact@v3
with:
name: onboard
path: ${{ env.ONBOARD_FILE_NAME }}
landside-docker:
runs-on: ubuntu-22.04
needs: [check-comment, core-docker]
env:
IMAGE_NAME: dukerobotics/robosub-ros:landside
BASE_IMAGE: dukerobotics/robosub-ros:core-amd64
SERVICE_NAME: landside
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.check-comment.outputs.sha }}
- name: Get core image
uses: actions/download-artifact@v3
with:
name: core
path: core_im
- name: Load core image
run: |
docker load < ./core_im/amd64-core.tar.gz
rm -rf core_im
- name: Setup environment and build docker image
run: |
cd docker/${SERVICE_NAME}
docker build --build-arg BASE_IMAGE=${BASE_IMAGE} -t ${IMAGE_NAME} .
- name: Save landside image
run: |
docker save ${IMAGE_NAME} | gzip > amd64-landside.tar.gz
- name: Create artifact from image
uses: actions/upload-artifact@v3
with:
name: landside
path: amd64-landside.tar.gz
cleanup-docker:
runs-on: ubuntu-22.04
needs: [check-comment, onboard-docker, landside-docker]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.check-comment.outputs.sha }}
- name: Cleanup artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: core