Skip to content

Commit

Permalink
Merge pull request #5 from canonical/disable-snap
Browse files Browse the repository at this point in the history
No inputs disables snap install
  • Loading branch information
barrettj12 authored Jan 18, 2023
2 parents 90d7610 + 7389828 commit 8e55622
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
sudo snap install juju --channel=3.0/stable
mkdir -p ~/.local/share
mkdir -p ~/.ssh
sudo snap connect juju:ssh-public-keys
sudo snap connect juju:ssh-keys
- name: Bootstrap
run: |
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test
on: [push, pull_request, workflow_dispatch]
jobs:

smoke:
name: Smoke
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Setup LXD
uses: ./
with:
channel: latest/stable

- name: Launch container
run: |
lxc launch ubuntu:
channel:
name: Channel
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Setup LXD
uses: ./
with:
channel: 5.0/stable

- name: Check LXD version
shell: bash
run: |
[[ $(lxd version) == 5.0* ]]
- name: Launch container
run: |
lxc launch ubuntu:
preinstalled:
name: Preinstalled
runs-on: ubuntu-20.04
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Setup LXD
uses: ./

- name: Check LXD version
shell: bash
run: |
[[ $(lxd version) == 4.0.9 ]]
- name: Launch container
run: |
lxc launch ubuntu:
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,56 @@
# setup-lxd

*NB: this action is currently in alpha, breaking changes can occur at any time.
Please pin a SHA or exact version in your CI.*

A GitHub Action which installs and configures the LXD snap on a runner.

By default, this action will install LXD from the `latest/stable` snap channel. You can specify a different channel using the `channel` input. (See `snap info lxd` for a list of available channels).
When run with no inputs:
```yaml
uses: canonical/setup-lxd
```
this action will use the LXD snap pre-installed on the runner. If LXD is not
installed, it will `sudo snap install lxd` from the default channel.

You can specify a snap channel with the `channel` input:
```yaml
uses: canonical/setup-lxd
with:
channel: 5.2/candidate
```
and then this action will install/refresh LXD from the specified channel.

## Example usage

```yaml
name: "Example"
name: "Install LXD 5.0"
on: push
jobs:
job1:
runs-on: ubuntu-latest
steps:
- name: Setup LXD
uses: canonical/setup-lxd@[sha]
uses: canonical/setup-lxd@[version]
with:
channel: 5.0/stable
channel: 5.0/stable # installs LXD 5.0.x
- name: Launch container
run: |
lxc launch ubuntu:22.04 u1
```

```yaml
name: "Configure pre-installed LXD"
on: push
jobs:
job1:
runs-on: ubuntu-22.04
steps:
- name: Setup LXD
uses: canonical/setup-lxd@[version]
# uses pre-installed LXD snap (v4.0.9)
- name: Launch container
run: |
Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ inputs:
channel:
description: 'Snap channel to install LXD from'
required: false
default: 'latest/stable'

runs:
using: "composite"
steps:

- name: Install LXD if not present
if: "${{ github.event.inputs.channel == '' }}"
shell: bash
run: |
if ! snap info lxd | grep "installed"; then
sudo snap install lxd
fi
- name: Install/refresh LXD snap
if: "${{ github.event.inputs.channel != '' }}"
shell: bash
run: |
set -x
Expand Down

0 comments on commit 8e55622

Please sign in to comment.