mirror of
https://github.com/actions/setup-java.git
synced 2026-06-24 00:30:28 +03:00
1d25252804
* Harden workflows with least-privilege permissions and zizmor
Apply GitHub Actions security best practices to the action's own
workflows and integrate zizmor to catch regressions.
- Add explicit least-privilege `permissions:` to every workflow
(contents: read for read-only workflows; default-deny `{}` with
job-scoped grants for codeql, publish-immutable-actions and
update-config-files).
- Set `persist-credentials: false` on all checkout steps that don't
need the GITHUB_TOKEN afterwards.
- Move `${{ ... }}` expansions out of `run:` blocks into `env:` vars
to avoid template injection.
- Pin the alpine container image (alpine:latest -> alpine:3.21).
- Add a zizmor CI workflow that uploads SARIF to code scanning, plus a
`.github/zizmor.yml` pinning policy (ref-pin for actions/* and
github/*, hash-pin for third-party actions).
zizmor now reports no findings (offline and online).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix indentation of if: in zizmor SARIF upload step
The `if:` key on the "Upload SARIF results to code scanning" step had no
indentation, producing invalid YAML ("Nested mappings are not allowed in
compact mappings"). This broke `npm run format-check` (prettier) in Basic
validation.
Indent `if:` to 8 spaces so it nests under the step alongside uses/with.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
140 lines
5.3 KiB
YAML
140 lines
5.3 KiB
YAML
name: Validate local file
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- releases/*
|
|
paths-ignore:
|
|
- '**.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
setup-java-local-file-adopt:
|
|
name: Validate installation from local file Adopt
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Download Adopt OpenJDK file
|
|
run: |
|
|
if ($IsLinux) {
|
|
$downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsMacOS) {
|
|
$downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsWindows) {
|
|
$downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.10_9.zip"
|
|
$localFilename = "java_package.zip"
|
|
}
|
|
echo "LocalFilename=$localFilename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
(New-Object System.Net.WebClient).DownloadFile($downloadUrl, "$env:RUNNER_TEMP/$localFilename")
|
|
shell: pwsh
|
|
- name: setup-java
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'jdkfile'
|
|
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
|
java-version: '11.0.0-ea'
|
|
architecture: x64
|
|
- name: Verify Java version
|
|
env:
|
|
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
run: bash __tests__/verify-java.sh "11.0.10" "$JAVA_PATH"
|
|
shell: bash
|
|
|
|
setup-java-local-file-zulu:
|
|
name: Validate installation from local file Zulu
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Download Zulu OpenJDK file
|
|
run: |
|
|
if ($IsLinux) {
|
|
$downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-linux_x64.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsMacOS) {
|
|
$downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-macosx_x64.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsWindows) {
|
|
$downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-win_x64.zip"
|
|
$localFilename = "java_package.zip"
|
|
}
|
|
echo "LocalFilename=$localFilename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
(New-Object System.Net.WebClient).DownloadFile($downloadUrl, "$env:RUNNER_TEMP/$localFilename")
|
|
shell: pwsh
|
|
- name: setup-java
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'jdkfile'
|
|
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
|
java-version: '11.0.0-ea'
|
|
architecture: x64
|
|
- name: Verify Java version
|
|
env:
|
|
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
run: bash __tests__/verify-java.sh "11.0" "$JAVA_PATH"
|
|
shell: bash
|
|
|
|
setup-java-local-file-temurin:
|
|
name: Validate installation from local file Eclipse Temurin
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Download Eclipse Temurin file
|
|
run: |
|
|
if ($IsLinux) {
|
|
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsMacOS) {
|
|
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.12_7.tar.gz"
|
|
$localFilename = "java_package.tar.gz"
|
|
} elseif ($IsWindows) {
|
|
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_windows_hotspot_11.0.12_7.zip"
|
|
$localFilename = "java_package.zip"
|
|
}
|
|
echo "LocalFilename=$localFilename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
(New-Object System.Net.WebClient).DownloadFile($downloadUrl, "$env:RUNNER_TEMP/$localFilename")
|
|
shell: pwsh
|
|
- name: setup-java
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'jdkfile'
|
|
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
|
java-version: '11.0.0-ea'
|
|
architecture: x64
|
|
- name: Verify Java version
|
|
env:
|
|
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
run: bash __tests__/verify-java.sh "11.0.12" "$JAVA_PATH"
|
|
shell: bash
|