Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/npm-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
# SPDX-License-Identifier: MIT

name: Build Javascript

on:
workflow_call:

permissions:
contents: read

concurrency:
group: node-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
src: ${{ steps.changes.outputs.src }}
steps:
- name: Detect frontend changes
id: changes
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- 'src/**'
- 'appinfo/info.xml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- '**.js'
- '**.ts'
- '**.vue'

build:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src != 'false'
name: NPM build
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Read package.json node and npm engines version
id: versions
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
with:
fallbackNode: '^24'
fallbackNpm: '^11.3'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Enforce package engine requirements
run: |
npm --version
npm config set engine-strict true

- name: Validate package-lock.json
run: |
npm exec --yes --package=npm-package-lock-add-resolved@1.1.4 -- npm-package-lock-add-resolved
git --no-pager diff --exit-code

- name: Install dependencies and build
env:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true
run: |
npm ci
npm run build --if-present

- name: Check build changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo 'Please recompile and commit the assets. See the "Show changes on failure" step for details.'
exit 1
fi

- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
exit 1

summary:
permissions:
contents: none
runs-on: ubuntu-latest
needs:
- changes
- build
if: always()
name: node
steps:
- name: Summary status
env:
CHANGED: ${{ needs.changes.outputs.src }}
BUILD_RESULT: ${{ needs.build.result }}
run: |
if [ "$CHANGED" != "false" ] && [ "$BUILD_RESULT" != "success" ]; then
exit 1
fi
11 changes: 11 additions & 0 deletions workflow-templates/npm-build.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Frontend build",
"description": "Install frontend dependencies, validate the lockfile, build assets and check for uncommitted build changes.",
"iconName": "octicon package",
"categories": [
"JavaScript"
],
"filePatterns": [
"^package.json$"
]
}
2 changes: 2 additions & 0 deletions workflow-templates/npm-build.properties.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
SPDX-License-Identifier: AGPL-3.0-or-later
16 changes: 16 additions & 0 deletions workflow-templates/npm-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
# SPDX-License-Identifier: AGPL-3.0-or-later

# This workflow is published through the LibreCode organization catalog.
# Implementation: LibreCodeCoop/github-workflows

name: Build Javascript

on: pull_request

permissions:
contents: read

jobs:
npm-build:
uses: LibreCodeCoop/github-workflows/.github/workflows/npm-build.yml@bab6f01a48474e6b00feb71882be2f4dafe928fc
Loading