Skip to content

Commit

Permalink
feat: Update nodejs builder to use BYOB (#1667)
Browse files Browse the repository at this point in the history
Updates the nodejs builder to use BYOB.

Publishing to npmjs.com will be done on a separate PR.

---------

Signed-off-by: Ian Lewis <ianlewis@google.com>
  • Loading branch information
ianlewis authored Feb 24, 2023
1 parent 4ed6a51 commit 478820e
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 623 deletions.
405 changes: 64 additions & 341 deletions .github/workflows/builder_nodejs_slsa3.yml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .github/workflows/delegator_generic_slsa3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ jobs:
echo "ACTION_PATH=$ACTION_PATH"
tree
- name: Checkout the project repository
uses: slsa-framework/slsa-github-generator/.github/actions/secure-project-checkout@main

Expand Down
1 change: 1 addition & 0 deletions internal/builders/nodejs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Generation of SLSA3+ provenance for npm packages
50 changes: 0 additions & 50 deletions internal/builders/nodejs/attest.go

This file was deleted.

109 changes: 0 additions & 109 deletions internal/builders/nodejs/build.go

This file was deleted.

56 changes: 0 additions & 56 deletions internal/builders/nodejs/main.go

This file was deleted.

33 changes: 0 additions & 33 deletions internal/builders/nodejs/publish.go

This file was deleted.

33 changes: 0 additions & 33 deletions internal/builders/nodejs/version.go

This file was deleted.

77 changes: 77 additions & 0 deletions internal/nodejs-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: SLSA3 Builder internal wrapper
description: SLSA3 Builder internal wrapper

inputs:
slsa-workflow-inputs:
description: "All the inputs formatted as a JSON map"
type: string
required: true

slsa-layout-file:
description: "Location to store the layout content"
type: string
required: true

slsa-workflow-secret1:
description: "secret1 is unused"
type: string
required: false

slsa-workflow-secret2:
description: "secret2 is unused"
type: string
required: false

runs:
using: "composite"
steps:
# NOTE: the repository is already cloned by the caller, so there's no need to
# checkout ourselves.

- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
always-auth: ${{ fromJson(inputs.slsa-workflow-inputs).always-auth }}
node-version: ${{ fromJson(inputs.slsa-workflow-inputs).node-version }}
node-version-file: ${{ fromJson(inputs.slsa-workflow-inputs).node-version-file }}
registry-url: ${{ fromJson(inputs.slsa-workflow-inputs).registry-url }}
scope: ${{ fromJson(inputs.slsa-workflow-inputs).scope }}
# TODO(#1679): cache dependencies.
# cache: npm
# NOTE: cache-dependency-path needs to be validated to be a subdirectory of GITHUB_WORKSPACE.
# cache-dependency-path:

# NOTE: the default npm lists incorrect filenames in the output of 'npm pack --json'. This is fixed in later versions.
- id: update-npm
shell: bash
run: |
npm install -g npm@9.5.0
- id: build
env:
UNTRUSTED_DIRECTORY: ${{ fromJson(inputs.slsa-workflow-inputs).directory }}
UNTRUSTED_RUN_SCRIPTS: ${{ fromJson(inputs.slsa-workflow-inputs).run-scripts }}
shell: bash
run: |
./../__TOOL_ACTION_DIR__/build.sh
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: package.tgz
path: ${{ steps.build.outputs.filename }}
if-no-files-found: error
retention-days: 5

# NOTE: Here we create a JSON file that describes the attestations we want
# to create. Each attestation will be created as a separate file,
# each with the subjects specified. This allows complicated release
# pipelines that output many artifacts to organize the attestations
# for those artifacts in a flexible way.
- name: Generate layout file
id: generate-layout
env:
SLSA_OUTPUTS_ARTIFACTS_FILE: ${{ inputs.slsa-layout-file }}
PACK_JSON: ${{ steps.build.outputs.pack_json }}
shell: bash
run: |
./../__TOOL_ACTION_DIR__/generate-layout.sh
Loading

0 comments on commit 478820e

Please sign in to comment.