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>
103 lines
2.8 KiB
YAML
103 lines
2.8 KiB
YAML
name: Validate cache with cache-dependency-path option
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- releases/*
|
|
paths-ignore:
|
|
- '**.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
gradle1-save:
|
|
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: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '17'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
- name: Create files to cache
|
|
# Need to avoid using Gradle daemon to stabilize the save process on Windows
|
|
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
|
run: |
|
|
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
|
if [ ! -d ~/.gradle/caches ]; then
|
|
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
exit 1
|
|
fi
|
|
gradle1-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
needs: gradle1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
- name: Confirm that ~/.gradle/caches directory has been made
|
|
run: |
|
|
if [ ! -d ~/.gradle/caches ]; then
|
|
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
|
exit 1
|
|
fi
|
|
ls ~/.gradle/caches/
|
|
gradle2-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
needs: gradle1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle2/*.gradle*
|
|
- name: Confirm that ~/.gradle/caches directory has not been made
|
|
run: |
|
|
if [ -d ~/.gradle/caches ]; then
|
|
echo "::error::The ~/.gradle/caches directory exists unexpectedly"
|
|
exit 1
|
|
fi
|