name: Node Build description: Install dependencies, build, and upload a build artifact inputs: INSTALL_CMD: description: "Install command" default: "npm ci" BUILD_SCRIPT: description: "npm script to run for the main build" default: "build:stage" EXTRA_BUILD_SCRIPT: description: "Optional additional npm script to run after the main build" default: "" ARTIFACT_NAME: description: "Name to give the uploaded artifact" default: "dist" ARTIFACT_PATH: description: "Path to upload as the artifact" default: "dist" COPY_PRISMA_ENGINE: description: "Copy the Prisma query engine binaries into the build directory" default: "false" WORKING_DIRECTORY: description: "Working directory for install, build, and artifact steps" default: "." UPLOAD_ARTIFACT: description: "Whether to upload the build artifact" default: "true" NPM_TOKEN: description: "Auth token for the private Gitea npm registry (@stat-tackler scope). Leave empty if the repo installs no private packages." default: "" runs: using: composite steps: - name: Checkout uses: actions/checkout@v4 - uses: actions/setup-node@v5 with: node-version-file: ${{ inputs.WORKING_DIRECTORY }}/package.json - name: Configure private registry auth if: inputs.NPM_TOKEN != '' shell: sh working-directory: ${{ inputs.WORKING_DIRECTORY }} run: | printf '%s\n%s\n' \ '@stat-tackler:registry=https://gitea.pixelparasol.com/api/packages/stat-tackler/npm/' \ '//gitea.pixelparasol.com/api/packages/stat-tackler/npm/:_authToken=${{ inputs.NPM_TOKEN }}' \ >> .npmrc - name: Install shell: sh working-directory: ${{ inputs.WORKING_DIRECTORY }} run: ${{ inputs.INSTALL_CMD }} - name: Build shell: sh working-directory: ${{ inputs.WORKING_DIRECTORY }} run: | npm run ${{ inputs.BUILD_SCRIPT }} if [ -n "${{ inputs.EXTRA_BUILD_SCRIPT }}" ]; then npm run ${{ inputs.EXTRA_BUILD_SCRIPT }} fi - name: Copy Prisma Client Engine if: inputs.COPY_PRISMA_ENGINE == 'true' shell: sh working-directory: ${{ inputs.WORKING_DIRECTORY }} run: | mkdir -p build/prisma cp node_modules/.prisma/client/libquery_engine-* build/prisma/ - name: Upload Build Artifact if: inputs.UPLOAD_ARTIFACT != 'false' uses: actions/upload-artifact@v3 with: name: ${{ inputs.ARTIFACT_NAME }} path: ${{ inputs.ARTIFACT_PATH }}