1+ name : CI
2+
3+ on :
4+ workflow_dispatch :
5+ pull_request :
6+ push :
7+
8+ jobs :
9+ deploy-blueos-extension :
10+ needs : test
11+ runs-on : ubuntu-latest
12+ env :
13+ PLATFORMS : " linux/arm/v7,linux/arm64/v8,linux/amd64"
14+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
15+
16+ steps :
17+ - name : Login to Docker Hub
18+ if : success() && github.event_name != 'pull_request'
19+ uses : docker/login-action@v2
20+ with :
21+ username : ${{ secrets.DOCKER_USERNAME }}
22+ password : ${{ secrets.DOCKER_PASSWORD }}
23+
24+ - name : Checkout
25+ uses : actions/checkout@v4
26+ with :
27+ submodules : recursive
28+
29+ - uses : oven-sh/setup-bun@v1
30+ with :
31+ bun-version : latest
32+
33+ - name : Build cockpit
34+ run : |
35+ bun install --frozen-lockfile
36+ bun run build
37+
38+ - name : Prepare
39+ id : prepare
40+ run : |
41+ # Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
42+ # If git tag matches semver, append latest tag to the push.
43+ DOCKER_IMAGE=${DOCKER_USERNAME:-bluerobotics}/cockpit
44+ VERSION=${GITHUB_REF##*/}
45+ if [[ $GITHUB_REF == refs/tags/* ]]; then
46+ VERSION=${GITHUB_REF#refs/tags/}
47+ fi
48+ TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
49+ if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
50+ TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
51+ fi
52+ echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
53+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
54+ echo "buildx_args=${TAGS} --file Dockerfile ." >> $GITHUB_OUTPUT
55+
56+ - name : Set up QEMU
57+ uses : docker/setup-qemu-action@v2
58+ with :
59+ platforms : all
60+
61+ - name : Set up Docker Buildx
62+ uses : docker/setup-buildx-action@v2
63+ with :
64+ version : latest
65+
66+ - name : Docker Buildx (build)
67+ run : |
68+ docker buildx build \
69+ --output "type=image,push=false" \
70+ --platform $PLATFORMS \
71+ ${{ steps.prepare.outputs.buildx_args }}
72+
73+ - name : Docker Buildx (push)
74+ if : success() && github.event_name != 'pull_request'
75+ run : |
76+ docker buildx build \
77+ --output "type=image,push=true" \
78+ --platform $PLATFORMS \
79+ ${{ steps.prepare.outputs.buildx_args }}
80+
81+ - name : Inspect image
82+ if : always() && github.event_name != 'pull_request'
83+ run : |
84+ docker buildx imagetools \
85+ inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
0 commit comments