Skip to content

Commit abfac77

Browse files
committed
Run Docker container as host user
1 parent 60f7f54 commit abfac77

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

.github/workflows/aur-update.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,19 @@ jobs:
143143
144144
- name: Generate .SRCINFO
145145
run: |
146-
# Use Arch Linux container to run makepkg
147-
docker run --rm -v "$PWD/aur-rustnet-bin:/pkg" archlinux:latest bash -c '
148-
pacman -Sy --noconfirm binutils fakeroot sudo &&
149-
useradd -m builder &&
150-
chown -R builder:builder /pkg &&
146+
# Use Arch Linux container to run makepkg as the host user
147+
docker run --rm -v "$PWD/aur-rustnet-bin:/pkg" --user $(id -u):$(id -g) archlinux:latest bash -c '
151148
cd /pkg &&
152-
sudo -u builder makepkg --printsrcinfo > .SRCINFO &&
153-
chown $(stat -c "%u:%g" PKGBUILD) .SRCINFO
154-
'
149+
makepkg --printsrcinfo > .SRCINFO
150+
' || {
151+
# If that fails (no write permissions), install tools as root then run as user
152+
docker run --rm -v "$PWD/aur-rustnet-bin:/pkg" archlinux:latest bash -c "
153+
pacman -Sy --noconfirm binutils fakeroot sudo &&
154+
useradd -m -u $(id -u) builder &&
155+
cd /pkg &&
156+
su builder -c 'makepkg --printsrcinfo > .SRCINFO'
157+
"
158+
}
155159
156160
echo ".SRCINFO generated successfully"
157161

0 commit comments

Comments
 (0)