Run docker with sudo in build-image

The default job image runs as a non-root user that lacks access to the
mounted docker socket.
This commit is contained in:
2026-06-12 11:30:28 -04:00
parent 6eecf6e4ac
commit e03afe0651
+9 -9
View File
@@ -19,25 +19,25 @@ jobs:
- name: Log in to registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" \
| docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin git.weaselab.dev
| sudo docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin git.weaselab.dev
- name: Build and push image if changed
run: |
image=git.weaselab.dev/weaselab/conflict-set-ci
tag="$(sha256sum Dockerfile .pre-commit-config.yaml | sha256sum | cut -c 1-16)-${{ matrix.arch }}"
latest=latest-${{ matrix.arch }}
if docker manifest inspect "$image:$tag" > /dev/null 2>&1; then
if [ "$(docker manifest inspect "$image:$tag")" = "$(docker manifest inspect "$image:$latest" 2> /dev/null)" ]; then
if sudo docker manifest inspect "$image:$tag" > /dev/null 2>&1; then
if [ "$(sudo docker manifest inspect "$image:$tag")" = "$(sudo docker manifest inspect "$image:$latest" 2> /dev/null)" ]; then
echo "$image:$latest is up to date"
else
docker pull "$image:$tag"
docker tag "$image:$tag" "$image:$latest"
docker push "$image:$latest"
sudo docker pull "$image:$tag"
sudo docker tag "$image:$tag" "$image:$latest"
sudo docker push "$image:$latest"
fi
else
docker build -t "$image:$tag" -t "$image:$latest" .
docker push "$image:$tag"
docker push "$image:$latest"
sudo docker build -t "$image:$tag" -t "$image:$latest" .
sudo docker push "$image:$tag"
sudo docker push "$image:$latest"
fi
pre-commit: