|
5 | 5 | name: common lint (called) |
6 | 6 | permissions: |
7 | 7 | contents: read |
| 8 | + pull-requests: read |
8 | 9 |
|
9 | 10 | on: |
10 | 11 | pull_request: |
|
15 | 16 | - synchronize |
16 | 17 | - reopened |
17 | 18 | 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]" |
18 | 27 |
|
19 | 28 | jobs: |
20 | 29 | lint: |
21 | 30 | name: Common Lint |
22 | | - runs-on: ubuntu-latest |
| 31 | + runs-on: ${{ (inputs && inputs.runner && fromJson(inputs.runner)) || 'ubuntu-latest' }} |
23 | 32 | env: |
24 | 33 | CLANG_FORMAT_VERSION: 20 |
25 | 34 | steps: |
|
69 | 78 |
|
70 | 79 | for name in "${!files[@]}"; do |
71 | 80 | if [ ! -f "${name}.json" ]; then |
72 | | - echo "Downloading ${name}.json" |
73 | 81 | url="${files[$name]}" |
| 82 | + echo "Downloading ${name}.json from ${url}" |
74 | 83 | curl \ |
75 | 84 | -fsSL \ |
76 | 85 | --retry 3 \ |
@@ -106,15 +115,22 @@ jobs: |
106 | 115 | - name: Install actionlint |
107 | 116 | id: get_actionlint |
108 | 117 | shell: bash |
| 118 | + env: |
| 119 | + ACTIONLINT_CONFIG: ${{ inputs.actionlint_config }} |
109 | 120 | run: | |
110 | 121 | bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) |
111 | 122 |
|
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" |
113 | 129 | curl \ |
114 | 130 | -fsSL \ |
115 | 131 | --retry 3 \ |
116 | 132 | -o ".github/actionlint.yml" \ |
117 | | - "https://raw.githubusercontent.com/LizardByte/.github/master/.github/actionlint.yml" |
| 133 | + ${url} |
118 | 134 | fi |
119 | 135 |
|
120 | 136 | - name: Replace shell |
@@ -354,6 +370,15 @@ jobs: |
354 | 370 | shell: pwsh |
355 | 371 | run: | |
356 | 372 | # 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 | + } |
357 | 382 |
|
358 | 383 | # To see a list of available rules, run the following command: |
359 | 384 | # Get-ScriptAnalyzerRule | Format-List |
|
0 commit comments