-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
156 lines (156 loc) · 5.57 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
name: "Disk Space Optimizer"
author: "hugoalh"
description: "Optimize disk space for GitHub hosted GitHub Actions runner."
inputs:
operate_async:
description: "[EXPERIMENTAL] {Boolean} Whether to operate in asynchronously to reduce the operation duration."
required: false
default: "False"
operate_sudo:
description: "{Boolean} Whether to execute this action in sudo mode on non-Windows environment."
required: false
default: "False"
general_include:
description: "{RegEx[]} Remove general item."
required: false
default: ""
general_exclude:
description: "{RegEx[]} Exclude remove general item."
required: false
default: ""
docker_include:
description: "{RegEx[]} Remove Docker image."
required: false
default: ""
docker_exclude:
description: "{RegEx[]} Exclude remove Docker image."
required: false
default: ""
docker_prune:
description: "{Boolean} Whether to prune Docker all of the dangling images."
required: false
default: "False"
docker_clean:
description: "{Boolean} Whether to remove Docker cache."
required: false
default: "False"
apt_enable:
description: "{Boolean} Whether to optimize via APT."
required: false
default: "False"
apt_prune:
description: "{Boolean} Whether to prune APT package."
required: false
default: "False"
apt_clean:
description: "{Boolean} Whether to remove APT cache."
required: false
default: "False"
chocolatey_enable:
description: "{Boolean} Whether to optimize via Chocolatey."
required: false
default: "False"
homebrew_enable:
description: "{Boolean} Whether to optimize via Homebrew."
required: false
default: "False"
homebrew_prune:
description: "{Boolean} Whether to prune Homebrew package."
required: false
default: "False"
homebrew_clean:
description: "{Boolean} Whether to remove Homebrew cache."
required: false
default: "False"
npm_enable:
description: "{Boolean} Whether to optimize via NPM."
required: false
default: "False"
npm_prune:
description: "{Boolean} Whether to prune NPM package."
required: false
default: "False"
npm_clean:
description: "{Boolean} Whether to remove NPM cache."
required: false
default: "False"
pipx_enable:
description: "{Boolean} Whether to optimize via Pipx."
required: false
default: "False"
wmic_enable:
description: "{Boolean} Whether to optimize via WMIC."
required: false
default: "False"
fs_enable:
description: "{Boolean} Whether to optimize via file system."
required: false
default: "False"
os_swap:
description: "{Boolean} Whether to remove system page/swap file."
required: false
default: "False"
runs:
using: "composite"
steps:
- name: "Setup PowerShell Toolkit"
uses: "hugoalh-studio/[email protected]"
with:
sudo: "${{inputs.operate_sudo}}"
version: "~2.1.0"
scope: "${{(inputs.operate_sudo == 'True' && 'AllUsers') || 'CurrentUser'}}"
continue-on-error: true
- name: "Main"
run: |
#Requires -PSEdition Core -Version 7.2
$Script:ErrorActionPreference = 'Stop'
Get-Alias -Scope 'Local' -ErrorAction 'SilentlyContinue' |
Remove-Alias -Scope 'Local' -Force -ErrorAction 'SilentlyContinue'
Import-Module -Name 'hugoalh.GitHubActionsToolkit' -Scope 'Local'
Test-GitHubActionsEnvironment -Mandatory
[String]$MainScriptPath = Join-Path -Path $Env:GITHUB_ACTION_PATH -ChildPath 'main.ps1'
If (!(Test-Path -LiteralPath $MainScriptPath -PathType 'Leaf')) {
Write-GitHubActionsFail -Message 'Invalid script path!'
}
[Boolean]$InputOperateSudo = [Boolean]::Parse($Env:INPUT_OPERATE_SUDO)
If ($InputOperateSudo -and $Env:RUNNER_OS -iin @('Linux', 'MacOS')) {
sudo --non-interactive --preserve-env pwsh -NonInteractive $MainScriptPath
}
Else {
pwsh -NonInteractive $MainScriptPath
}
shell: "pwsh"
env:
INPUT_APT_CLEAN: "${{inputs.apt_clean}}"
INPUT_APT_ENABLE: "${{inputs.apt_enable}}"
INPUT_APT_PRUNE: "${{inputs.apt_prune}}"
INPUT_CHOCOLATEY_ENABLE: "${{inputs.chocolatey_enable}}"
INPUT_DOCKER_CLEAN: "${{inputs.docker_clean}}"
INPUT_DOCKER_EXCLUDE: "${{inputs.docker_exclude}}"
INPUT_DOCKER_INCLUDE: "${{inputs.docker_include}}"
INPUT_DOCKER_PRUNE: "${{inputs.docker_prune}}"
INPUT_FS_ENABLE: "${{inputs.fs_enable}}"
INPUT_GENERAL_EXCLUDE: "${{inputs.general_exclude}}"
INPUT_GENERAL_INCLUDE: "${{inputs.general_include}}"
INPUT_HOMEBREW_CLEAN: "${{inputs.homebrew_clean}}"
INPUT_HOMEBREW_ENABLE: "${{inputs.homebrew_enable}}"
INPUT_HOMEBREW_PRUNE: "${{inputs.homebrew_prune}}"
INPUT_NPM_CLEAN: "${{inputs.npm_clean}}"
INPUT_NPM_ENABLE: "${{inputs.npm_enable}}"
INPUT_NPM_PRUNE: "${{inputs.npm_prune}}"
INPUT_OPERATE_ASYNC: "${{inputs.operate_async}}"
INPUT_OPERATE_SUDO: "${{inputs.operate_sudo}}"
INPUT_OS_SWAP: "${{inputs.os_swap}}"
INPUT_PIPX_ENABLE: "${{inputs.pipx_enable}}"
INPUT_WMIC_ENABLE: "${{inputs.wmic_enable}}"
continue-on-error: true
- name: "Setup PowerShell Toolkit"
uses: "hugoalh-studio/[email protected]"
with:
sudo: "${{inputs.operate_sudo}}"
version: "False"
continue-on-error: true
branding:
icon: "hard-drive"
color: "green"