From e98b1d683b6a39341dbe74c122126d6bc6d0becc Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 20 Oct 2023 19:26:03 -0700 Subject: Try making snap cache work again --- .github/workflows/build.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cb1775f..13463e42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -261,32 +261,39 @@ jobs: steps: - uses: actions/checkout@v3 - # Change permissions before caching - - name: Set permissions for caching - run: sudo chmod -R 777 /var/snap/lxd/common/lxd/storage-pools/default - continue-on-error: true + - name: Initialize LXD/LXC + run: | + sudo lxd init --auto + sudo lxc storage list + + - name: Prepare cacheable directory + run: mkdir -p ~/lxd_cache - name: Restore cache - lxd uses: actions/cache@v3 with: - path: /var/snap/lxd/common/lxd/storage-pools/default + path: ~/lxd_cache key: snap-lxd-${{ hashFiles('snap/snapcraft.yaml') }} - # Restore original permissions after caching - - name: Restore permissions after caching - run: sudo chmod -R 755 /var/snap/lxd/common/lxd/storage-pools/default - continue-on-error: true + - name: Restore cached content to lxd directory + run: | + if [ -d "~/lxd_cache" ]; then + sudo rsync -a ~/lxd_cache/ /var/snap/lxd/common/lxd/storage-pools/default/ + fi - name: Install dependencies run: | - sudo lxd init --auto - sudo lxc storage list sudo snap install snapcraft --classic sudo ufw disable - name: Build snap run: sudo snapcraft + - name: Copy lxd directory to cacheable directory + run: | + sudo rsync -a /var/snap/lxd/common/lxd/storage-pools/default/ ~/lxd_cache/ + sudo chown -R $USER:$USER ~/lxd_cache/ + - uses: actions/upload-artifact@v3 with: name: snapcraft-build -- cgit v1.2.3-54-g00ecf