Skip to content

Commit 69e83cd

Browse files
feat: customize runners
1 parent 4b74dc7 commit 69e83cd

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/__call-common-lint.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
name: common lint (called)
66
permissions:
77
contents: read
8+
pull-requests: read
89

910
on:
1011
pull_request:
@@ -15,11 +16,19 @@ on:
1516
- synchronize
1617
- reopened
1718
workflow_call:
19+
inputs:
20+
actionlint_config:
21+
required: false
22+
type: string
23+
runner:
24+
required: false
25+
type: string
26+
default: "[ubuntu-latest]"
1827

1928
jobs:
2029
lint:
2130
name: Common Lint
22-
runs-on: ubuntu-latest
31+
runs-on: ${{ (inputs && inputs.runner && fromJson(inputs.runner)) || 'ubuntu-latest' }}
2332
env:
2433
CLANG_FORMAT_VERSION: 20
2534
steps:
@@ -69,8 +78,8 @@ jobs:
6978
7079
for name in "${!files[@]}"; do
7180
if [ ! -f "${name}.json" ]; then
72-
echo "Downloading ${name}.json"
7381
url="${files[$name]}"
82+
echo "Downloading ${name}.json from ${url}"
7483
curl \
7584
-fsSL \
7685
--retry 3 \
@@ -106,15 +115,22 @@ jobs:
106115
- name: Install actionlint
107116
id: get_actionlint
108117
shell: bash
118+
env:
119+
ACTIONLINT_CONFIG: ${{ inputs.actionlint_config }}
109120
run: |
110121
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
111122
112-
if [ ! -f ".github/actionlint.yml" ]; then
123+
if [ -n "${ACTIONLINT_CONFIG}" ]; then
124+
mkdir -p .github
125+
printf "%s" "${ACTIONLINT_CONFIG}" > .github/actionlint.yml
126+
elif [ ! -f ".github/actionlint.yml" ]; then
127+
url="https://raw.githubusercontent.com/LizardByte/.github/master/.github/actionlint.yml"
128+
echo "Downloading ${url} with curl"
113129
curl \
114130
-fsSL \
115131
--retry 3 \
116132
-o ".github/actionlint.yml" \
117-
"https://raw.githubusercontent.com/LizardByte/.github/master/.github/actionlint.yml"
133+
${url}
118134
fi
119135
120136
- name: Replace shell
@@ -354,6 +370,15 @@ jobs:
354370
shell: pwsh
355371
run: |
356372
# PSScriptAnalyzer is already installed on GitHub runners
373+
if ($env:RUNNER_NAME -notlike 'GitHub Actions*') {
374+
$repo = Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue
375+
if (-not $repo) {
376+
Register-PSRepository -Default -InstallationPolicy Trusted
377+
} else {
378+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
379+
}
380+
Install-Module -Name PSScriptAnalyzer -Force
381+
}
357382
358383
# To see a list of available rules, run the following command:
359384
# Get-ScriptAnalyzerRule | Format-List

0 commit comments

Comments
 (0)