-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (97 loc) · 3.83 KB
/
docker-build-pc.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
name: docker-build-pc
on:
workflow_dispatch:
env:
SDK_DIR: ${{ github.workspace }}
GH_TOKEN: ${{ secrets.GHCR_PAT }}
jobs:
build_pc:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Initial setup for the SDK repository
run: |
SDK_DIR=$SDK_DIR $SDK_DIR/scripts/install_gscam.sh
SDK_DIR=$SDK_DIR $SDK_DIR/scripts/install_mmwave_rospkg.sh
# verify
ls -l $SDK_DIR/ros2/drivers
- name: Set up j7ros_home folder and parse SDK_VER
run: |
mkdir -p $HOME/j7ros_home
cd $HOME/j7ros_home
makefile_path=$SDK_DIR/docker/Makefile
if [ -f $makefile_path ]; then
ln -snf $SDK_DIR/docker/Makefile .
else
echo "Error: $makefile_path does not exist"
exit 1
fi
OUTPUT=$(make info)
SDK_VER=$(echo "$OUTPUT" | grep 'SDK_VER:' | awk '{print $2}')
echo "Parsed SDK_VER: $SDK_VER"
echo "SDK_VER=$SDK_VER" >> $GITHUB_ENV
- name: Set up Docker build script
run: |
cd $HOME/j7ros_home
PLATFORM=pc SDK_DIR=$SDK_DIR make scripts
# verify
ls -l $HOME/j7ros_home
more $HOME/j7ros_home/docker_build.sh
- name: Build Docker image
run: |
cd $HOME/j7ros_home
./docker_build.sh
- name: Build and install the SDK ROS nodes
run: |
cd $HOME/j7ros_home
# create docker_run_commit.sh
script_file=docker_run_commit.sh
cp docker_run.sh $script_file
sed -i 's/docker run -it --rm \\/docker run --platform linux\/amd64 \\/' $script_file
sed -i '/xhost +local:$USER/d' $script_file
sed -i '/xhost -local:$USER/d' $script_file
echo 'CONTAINER_ID=$(docker ps -a --filter "ancestor=$DOCKER_TAG" --format "{{.ID}}" | head -n 1)' >> $script_file
echo 'docker tag $DOCKER_TAG ${DOCKER_TAG}-org' >> $script_file
echo 'docker commit $CONTAINER_ID ${DOCKER_TAG}' >> $script_file
more $script_file
# build and install the SDK ROS nodes
./docker_run_commit.sh colcon build \
--base-paths /root/j7ros_home/ros_ws/src/robotics_sdk/ros2 \
--cmake-force-configure \
--packages-skip ti_external ti_vision_cnn ti_sde ti_estop ti_vl ti_objdet_range ti_ros_gst_plugins \
--install-base /opt/ros/robotics_sdk_install
docker images
- name: Add a Docker label
run: |
docker_tag=robotics-sdk:${{ env.SDK_VER }}-humble-viz
docker images
if [ "$(docker images -q $docker_tag 2> /dev/null)" == "" ]; then
echo "Docker image $docker_tag does not exist."
exit 1
else
echo "FROM --platform=linux/amd64 $docker_tag" | \
docker build --label org.opencontainers.image.source=https://github.com/${{ github.repository }} -t $docker_tag -
docker inspect --format='{{json .Config.Labels}}' $docker_tag
fi
- name: Push Docker image
run: |
docker_tag=robotics-sdk:${{ env.SDK_VER }}-humble-viz
remote_docker_tag=ghcr.io/${{ github.repository_owner }}/$docker_tag
remote_docker_tag=${remote_docker_tag,,}
docker tag $docker_tag $remote_docker_tag
for i in 1 2 3; do
if docker push $remote_docker_tag; then
break
fi
echo "Retry $i pushing image..."
sleep 10
done