mirror of
https://github.com/chenasraf/workflows.git
synced 2026-05-17 17:28:03 +00:00
93 lines
2.0 KiB
YAML
93 lines
2.0 KiB
YAML
# Reusable workflow for NPM build verification
|
|
#
|
|
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
name: Build NPM
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
build-command:
|
|
description: 'Command to run build'
|
|
required: false
|
|
type: string
|
|
default: 'pnpm build'
|
|
path-filters:
|
|
description: 'Paths to filter on (YAML format)'
|
|
required: false
|
|
type: string
|
|
default: |
|
|
- '.github/workflows/**'
|
|
- 'src/**'
|
|
- '*.ts'
|
|
- '*.js'
|
|
- '*.json'
|
|
- '*.yaml'
|
|
- 'pnpm-lock.yaml'
|
|
|
|
permissions:
|
|
pull-requests: read
|
|
contents: read
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
src: ${{ steps.changes.outputs.src }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build filters
|
|
id: build-filters
|
|
run: |
|
|
echo "yaml<<EOF" >> $GITHUB_OUTPUT
|
|
echo "src:" >> $GITHUB_OUTPUT
|
|
echo '${{ inputs.path-filters }}' | sed 's/^/ /' >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
- uses: dorny/paths-filter@v3
|
|
id: changes
|
|
continue-on-error: true
|
|
with:
|
|
filters: ${{ steps.build-filters.outputs.yaml }}
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: changes
|
|
if: needs.changes.outputs.src == 'true'
|
|
|
|
name: PNPM Build
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
env:
|
|
CYPRESS_INSTALL_BINARY: 0
|
|
PUPPETEER_SKIP_DOWNLOAD: true
|
|
run: |
|
|
npm i -g pnpm
|
|
pnpm i --frozen-lockfile
|
|
|
|
- name: Build
|
|
run: ${{ inputs.build-command }}
|
|
|
|
summary:
|
|
permissions:
|
|
contents: none
|
|
runs-on: ubuntu-latest
|
|
needs: [changes, build]
|
|
|
|
if: always()
|
|
|
|
name: build-npm-summary
|
|
|
|
steps:
|
|
- name: Summary status
|
|
run: if ${{ needs.changes.outputs.src == 'true' && needs.build.result != 'success' }}; then exit 1; fi
|