If this is your first time running LXD on this machine, you should also run: lxd init
Error: LXD unix socket "/var/snap/lxd/common/lxd/unix.socket" not accessible: permission denied
Error: Process completed with exit code 1.
workflow.yml
name: Test Linux Snapcraft (arm64)
on:
workflow_dispatch:
# Declare default permissions as readonly.
permissions: read-all
jobs:
snap:
name: Create linux snap (aarch64)
runs-on: buildjet-4vcpu-ubuntu-2204-arm
env:
LXD_GROUP: lxd
steps:
- uses: actions/checkout@v4
- name: Install yq
run: |
if ! command -v yq >/dev/null 2>&1; then
echo "yq not exists"
sudo snap install -y yq
fi
yq --version
- name: Configure .env
run: |
echo "$ENV_KEY" | base64 --decode > .env
env:
ENV_KEY: ${{ secrets.ENV_STG_BASE64 }}
- name: Setup LXD
uses: canonical/setup-lxd@main
with:
group: ${{ env.LXD_GROUP }}
channel: latest/stable
- name: Add user to the LXD (lxd) group
run: |
sudo usermod -a -G $LXD_GROUP $USER
sudo snap services --global lxd
newgrp $LXD_GROUP
getent group $LXD_GROUP
- name: Check LXD status
run: lxc launch ubuntu:22.04 testlxd
- name: Update snapcraft.yaml
run: |
rm -f snap/snapcraft.yaml
mv snap/snapcraft-arm64.yaml snap/snapcraft.yaml
- name: Install snapcraft
run: sudo snap install snapcraft --classic
- name: Build snap
run: |
# https://snapcraft.io/docs/flutter-applications
version=$(yq '.version' pubspec.yaml)
snapcraft --output "picguard_"$version"_linux_aarch64.snap"
# Package the build.
- name: Copy build for snap
run: ls -la *.snap
- uses: actions/upload-artifact@v4
with:
name: linux-snap-artifact
path: |
./*.snap
- name: Clean up
if: ${{ always() }}
run: |
rm -f .env
if which snapcraft >/dev/null 2>&1; then
echo "snapcraft exists"
snapcraft clean
fi
The following code contains the sudo usermod -a -G $LXD_GROUP $USER command, LXD_GROUP is an environment variable, and its value is lxd
- name: Add user to the LXD (lxd) group
run: |
sudo usermod -a -G $LXD_GROUP $USER
sudo snap services --global lxd
newgrp $LXD_GROUP
getent group $LXD_GROUP
Unless I’m mistaken, this part of the code seems incorrect, you added the user to the group before the group was even created or existed :
- name: Add user to the LXD (lxd) group
run: |
sudo usermod -a -G $LXD_GROUP $USER
sudo snap services --global lxd
newgrp $LXD_GROUP
getent group $LXD_GROUP