Skip to content

ci(sync): update GitHub Actions#90

Merged
alexpriv8 merged 1 commit into
masterfrom
ci/sync-github-actions-74df516
Jul 21, 2026
Merged

ci(sync): update GitHub Actions#90
alexpriv8 merged 1 commit into
masterfrom
ci/sync-github-actions-74df516

Conversation

@indykiteone

Copy link
Copy Markdown
Contributor

Automatically generated PR to sync GitHub Actions and related configs.

Copilot AI review requested due to automatic review settings July 21, 2026 16:38
@indykiteone
indykiteone requested a review from a team July 21, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared composite pre-commit GitHub Action to better align Node.js dependency caching with the package manager actually used by the repository (based on detected lockfiles).

Changes:

  • Add lockfile-based detection to choose the appropriate actions/setup-node cache mode (npm/yarn/pnpm) and dependency path.
  • Add validation logic around Node hook detection vs. presence of supported lockfiles.
  • Wire setup-node to use the dynamically detected cache settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/actions/pre-commit/action.yaml
Comment on lines +57 to +72
# Detect Node package manager cache strategy from lockfile presence.
NODE_CACHE=""
NODE_CACHE_DEPENDENCY_PATH=""
if [[ -f "pnpm-lock.yaml" ]]; then
NODE_CACHE="pnpm"
NODE_CACHE_DEPENDENCY_PATH="pnpm-lock.yaml"
elif [[ -f "package-lock.json" ]]; then
NODE_CACHE="npm"
NODE_CACHE_DEPENDENCY_PATH="package-lock.json"
elif [[ -f "npm-shrinkwrap.json" ]]; then
NODE_CACHE="npm"
NODE_CACHE_DEPENDENCY_PATH="npm-shrinkwrap.json"
elif [[ -f "yarn.lock" ]]; then
NODE_CACHE="yarn"
NODE_CACHE_DEPENDENCY_PATH="yarn.lock"
fi
Comment thread .github/actions/pre-commit/action.yaml Outdated
Comment on lines +79 to +84
IS_NPM=$(grep -E "(npm|node)" "$_CONFIG" | grep -cv "language: node")
if [[ "$IS_NPM" -gt 0 && -z "$NODE_CACHE" ]]; then
echo "[ERROR] Node hooks detected in ${_CONFIG}, but no supported lockfile found."
echo "[ERROR] Expected one of: pnpm-lock.yaml, package-lock.json, npm-shrinkwrap.json, yarn.lock"
exit 1
fi
Copilot AI review requested due to automatic review settings July 21, 2026 17:31
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from 6152de4 to e8ad8cd Compare July 21, 2026 17:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/actions/pre-commit/action.yaml
Comment on lines 101 to 102
echo "IS_TERRAFORM=$(grep -c "terraform" "$_CONFIG")"
echo "IS_GOLANG=${IS_GOLANG:-$(grep -E "\<(go|golang)\>" "$_CONFIG" | grep -vEc "(language: go|gone|- repo)")}"
Copilot AI review requested due to automatic review settings July 21, 2026 17:47
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from e8ad8cd to 6dc1456 Compare July 21, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread .github/actions/pre-commit/script.sh Outdated
Comment on lines +194 to +198
case "${NPM_CACHE:-}" in
pnpm)
pnpm install --frozen-lockfile --ignore-scripts
;;
npm)
Comment thread .github/actions/pre-commit/action.yaml Outdated
Comment on lines +181 to +185
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - https://github.com/actions/setup-node/releases
with:
node-version: latest
node-version-file: "package.json"
cache: "npm"
node-version-file: ${{ steps.action-prep.outputs.NODE_VERSION_FILE }}
cache: ${{ steps.action-prep.outputs.NODE_CACHE }}
cache-dependency-path: ${{ steps.action-prep.outputs.NODE_CACHE_DEPENDENCY_PATH }}
Comment on lines +76 to +82
if [[ -f "package.json" ]]; then
NODE_VERSION_FILE="package.json"
PACKAGE_MANAGER=$(python3 -c 'import json,sys; print(json.load(open("package.json")).get("packageManager", ""))' 2>/dev/null || true)
if [[ "$PACKAGE_MANAGER" == pnpm@* ]]; then
PNPM_VERSION="${PACKAGE_MANAGER#pnpm@}"
fi
fi
Copilot AI review requested due to automatic review settings July 21, 2026 17:56
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from 6dc1456 to 3e214b7 Compare July 21, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

.github/actions/pre-commit/action.yaml:185

  • actions/setup-node is configured with only node-version-file, but NODE_VERSION_FILE can be empty when a repo has Node hooks/lockfiles without a root package.json (e.g., workspace setups). Passing an empty node-version-file can cause the setup step to fail; add a fallback that sets an explicit Node version when NODE_VERSION_FILE is empty.
      uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - https://github.com/actions/setup-node/releases
      with:
        node-version-file: ${{ steps.action-prep.outputs.NODE_VERSION_FILE }}
        cache: ${{ steps.action-prep.outputs.NODE_PM }}
        cache-dependency-path: ${{ steps.action-prep.outputs.NODE_PM_LOCKFILE }}

.github/actions/pre-commit/action.yaml:102

  • The grep -c / grep pipeline results are used to populate outputs, but grep returns exit status 1 when there are no matches; with the default GitHub Actions bash options (-e/pipefail), that can terminate the step even though a 0 count is expected. Consider making these greps non-fatal and defaulting the count to 0.
            echo "IS_TERRAFORM=$(grep -c "terraform" "$_CONFIG")"
            echo "IS_GOLANG=${IS_GOLANG:-$(grep -E "\<(go|golang)\>" "$_CONFIG" | grep -vEc "(language: go|gone|- repo)")}"

Copilot AI review requested due to automatic review settings July 21, 2026 18:06
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from 3e214b7 to 30c0382 Compare July 21, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

.github/actions/pre-commit/action.yaml:185

  • actions/setup-node no longer sets an explicit Node version. When NODE_VERSION_FILE is empty (e.g., no package.json), the job will fall back to the runner’s preinstalled Node version, which can drift over time and make pre-commit runs less reproducible. Consider adding an explicit fallback version (keeping the previous latest behavior) while still allowing node-version-file to override when present.
      with:
        node-version-file: ${{ steps.action-prep.outputs.NODE_VERSION_FILE }}
        cache: ${{ steps.action-prep.outputs.NODE_PM }}
        cache-dependency-path: ${{ steps.action-prep.outputs.NODE_PM_LOCKFILE }}

Comment thread .github/actions/pre-commit/script.sh
Copilot AI review requested due to automatic review settings July 21, 2026 18:26
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from 30c0382 to e249de2 Compare July 21, 2026 18:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

.github/actions/pre-commit/action.yaml:185

  • actions/setup-node is now configured with only node-version-file. When NODE_VERSION_FILE is empty (e.g., no root package.json) or the file doesn’t contain an engines-based Node version, setup-node can fail because no Node version is specified. Consider keeping a safe fallback (e.g., node-version: latest) so Node hooks still work when a version file is absent or non-informative.
    - name: setup/node
      uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - https://github.com/actions/setup-node/releases
      with:
        node-version-file: ${{ steps.action-prep.outputs.NODE_VERSION_FILE }}
        cache: ${{ steps.action-prep.outputs.NODE_PM }}
        cache-dependency-path: ${{ steps.action-prep.outputs.NODE_PM_LOCKFILE }}

Comment on lines +192 to +199
# Ensure pnpm can resolve private @fortawesome packages during setup/pre-commit.
# HACK: workaround for 'frontend-monorepo', TBD for generic cases
if [[ -n "${NODE_AUTH_TOKEN:-}" ]]; then
{
echo "@fortawesome:registry=https://npm.fontawesome.com/"
echo "//npm.fontawesome.com/:_authToken=${NODE_AUTH_TOKEN}"
} >>"${HOME}/.npmrc"
fi
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 18:44
@indykiteone
indykiteone force-pushed the ci/sync-github-actions-74df516 branch from e249de2 to 0cdd121 Compare July 21, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

.github/actions/pre-commit/action.yaml:102

  • The bash snippet writing outputs to $GITHUB_OUTPUT has unescaped nested double-quotes in the command substitutions (e.g., grep -c "terraform" and grep -E "\<(go|golang)\>"), which will cause a syntax error when this step runs.
            echo "IS_TERRAFORM=$(grep -c "terraform" "$_CONFIG")"
            echo "IS_GOLANG=${IS_GOLANG:-$(grep -E "\<(go|golang)\>" "$_CONFIG" | grep -vEc "(language: go|gone|- repo)")}"

.github/actions/pre-commit/action.yaml:189

  • actions/setup-node is always invoked with node-version-file sourced from NODE_VERSION_FILE, but NODE_VERSION_FILE is set only when package.json exists. If a repo has Node hooks + a supported lockfile but no package.json (or uses a different version file like .nvmrc), this will pass an empty path and likely fail the action.
    - name: setup/node
      uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - https://github.com/actions/setup-node/releases
      with:
        node-version-file: ${{ steps.action-prep.outputs.NODE_VERSION_FILE }}
        cache: ${{ steps.action-prep.outputs.NODE_PM }}
        cache-dependency-path: ${{ steps.action-prep.outputs.NODE_PM_LOCKFILE }}
      if: >-
        steps.action-prep.outputs.PRE_COMMIT_RUN == '1'
        && steps.action-prep.outputs.IS_NPM > 0
        && ((github.event_name != 'pull_request' && !steps.cache.outputs.cache-hit) || github.event_name == 'pull_request')

@alexpriv8
alexpriv8 merged commit a54e5b0 into master Jul 21, 2026
7 of 8 checks passed
@alexpriv8
alexpriv8 deleted the ci/sync-github-actions-74df516 branch July 21, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants