Skip to content

Commit

Permalink
feat: allow skipping distro installation
Browse files Browse the repository at this point in the history
  • Loading branch information
vedantmgoyal9 authored Nov 22, 2024
1 parent f78c267 commit 301e387
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ on:
jobs:
test:
runs-on: windows-latest
strategy:
matrix:
distro: [Ubuntu, none]
steps:
- uses: actions/checkout@v4.1.1
- uses: ./
- name: Run a one-line script
with:
distro: ${{ matrix.distro }}
- if: ${{ matrix.distro != 'none' }}
run: cat /etc/os-release && uname -a
shell: wsl-run {0}
- name: Run a multi-line script
- if: ${{ matrix.distro != 'none' }}
name: Run a multi-line script
run: |
ls -alh
cat ${0} # prints the script itself
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ It also enables systemd support if you are using `windows-2022`/`windows-latest`

### Inputs

| Input | Description | Default |
| ---------------- | ------------------------------------------------------------------------------------------------ | -------- |
| `distro` | The Linux distro to install. You can use any distro which is available in `wsl --list --online`. | `Ubuntu` |
| `enable-systemd` | Enable systemd.<br>**Note:** Please set it to `false` if you are using `windows-2019` runner. | `true` |
| Input | Description | Default |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `distro` | The Linux distro to install. You can use any distro which is available in `wsl --list --online`.<br>**Note:** Use `none` to skip installing any distro. | `Ubuntu` |
| `enable-systemd` | Enable systemd.<br>**Note:** Please set it to `false` if you are using `windows-2019` runner. | `true` |

### Example Usage

Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
enable-systemd:
description: |
Enable systemd support. Default is true.
Note: Please disable this if you are using Windows Server 2019 GitHub-hosted runners.
Note: Please disable this if you are using `windows-2019` runner.
required: true
default: 'true'
runs:
Expand All @@ -27,14 +27,18 @@ runs:
run: |
# check if systemd is supported
if ((Get-ComputerInfo -Property OsName).OsName.Contains('2019')) {
Write-Output 'systemd is not supported on windows server 2019'
Write-Output 'systemd is not supported on windows-2019 runners.'
exit 1
}
shell: pwsh
- run: |
# update WSL, download & install ${{ inputs.distro }}
Set-Service -Name StorSvc -StartupType Automatic
wsl --set-default-version 2; wsl --update; wsl --status;
if ('${{ inputs.distro }}' -eq 'none') {
Write-Output 'Skipping distro installation...'
return
}
$distros = (Invoke-RestMethod -Uri https://raw.githubusercontent.com/microsoft/WSL/refs/heads/master/distributions/DistributionInfo.json).Distributions
if ($distros.Name -notcontains '${{ inputs.distro }}') {
Write-Output 'Invalid distro: ${{ inputs.distro }}'
Expand Down

0 comments on commit 301e387

Please sign in to comment.