diff --git a/.forgejo/actions/build-node-app/action.yaml b/.forgejo/actions/build-node-app/action.yaml new file mode 100644 index 0000000..ea0d16e --- /dev/null +++ b/.forgejo/actions/build-node-app/action.yaml @@ -0,0 +1,54 @@ +name: Verify package.json version +description: This action build a nodejs app, and run the tests + +inputs: + test_action: + description: Name of the test script + default: test + required: false + + build_action: + description: Name of the build script + default: build + required: false + + build_path: + description: Path of the build output + default: dist + required: false + + artifact_name: + description: Name for the generated artifact + default: dist + required: false + +runs: + using: composite + steps: + - name: Install dependencies + shell: sh + run: apk add nodejs + + - name: Git Clone + uses: actions/checkout@v4 + + - name: Restore Node Modules Cache + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-nodejs-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-nodejs- + + - name: Build and Test + shell: sh + run: | + npm install + npm run ${{ inputs.test_action }} + npm run ${{ inputs.build_action }} + + - uses: actions/upload-artifact@v3 + name: Upload Artifact + with: + name: ${{ inputs.artifact_name }} + path: ${{ inputs.build_path }}