|
23 | 23 | type: boolean |
24 | 24 | required: false |
25 | 25 | default: true |
| 26 | + rename-after-install-and-build: |
| 27 | + description: 'Governs where in the workflow that packages in the repo are renamed to use the preview build scope. If true, this step runs after the install and build steps; if false (default), it runs before. This option is mostly for Snaps so that artifacts (e.g. dist/bundle.js, snap.manifest.json) capture the original package name, not the preview build name.' |
| 28 | + type: boolean |
| 29 | + required: false |
| 30 | + default: false |
26 | 31 | environment: |
27 | 32 | description: 'GitHub environment for the publish job (e.g., default-branch). Empty = no gate.' |
28 | 33 | type: string |
|
46 | 51 | secrets: |
47 | 52 | PUBLISH_PREVIEW_NPM_TOKEN: |
48 | 53 | required: true |
| 54 | + BUILD_ENV: |
| 55 | + description: 'JSON object of environment variables to pass to the build step (e.g. ''{"FOO":"bar","API_URL":"https://..."}''). Use this for build-time configuration and secrets needed by the build command.' |
| 56 | + required: false |
49 | 57 |
|
50 | 58 | jobs: |
51 | 59 | is-fork-pull-request: |
@@ -100,7 +108,28 @@ jobs: |
100 | 108 | id: commit-sha |
101 | 109 | run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
102 | 110 |
|
103 | | - - name: Prepare preview builds |
| 111 | + - name: Install dependencies (pre-build) |
| 112 | + if: ${{ inputs.rename-after-install-and-build }} |
| 113 | + run: yarn install --no-immutable |
| 114 | + |
| 115 | + - name: Mask build environment values |
| 116 | + env: |
| 117 | + BUILD_ENV: ${{ secrets.BUILD_ENV }} |
| 118 | + run: | |
| 119 | + if [[ -n "$BUILD_ENV" ]]; then |
| 120 | + while IFS= read -r line; do |
| 121 | + if [[ -n "$line" ]]; then |
| 122 | + echo "::add-mask::$line" |
| 123 | + fi |
| 124 | + done < <(jq --raw-output '.[] | tostring' <<< "$BUILD_ENV") |
| 125 | + fi |
| 126 | +
|
| 127 | + - name: Build (pre-rename) |
| 128 | + if: ${{ inputs.rename-after-install-and-build }} |
| 129 | + env: ${{ fromJSON(secrets.BUILD_ENV || '{}') }} |
| 130 | + run: ${{ inputs.build-command }} |
| 131 | + |
| 132 | + - name: Prepare preview manifests |
104 | 133 | env: |
105 | 134 | NPM_SCOPE: ${{ inputs.npm-scope }} |
106 | 135 | COMMIT_SHA: ${{ steps.commit-sha.outputs.COMMIT_SHA }} |
@@ -139,10 +168,12 @@ jobs: |
139 | 168 | prepare_manifest package.json |
140 | 169 | fi |
141 | 170 |
|
142 | | - echo "Installing dependencies..." |
143 | | - yarn install --no-immutable |
| 171 | + - name: Install dependencies |
| 172 | + run: yarn install --no-immutable |
144 | 173 |
|
145 | | - - name: Build |
| 174 | + - name: Build (post-rename) |
| 175 | + if: ${{ !inputs.rename-after-install-and-build }} |
| 176 | + env: ${{ fromJSON(secrets.BUILD_ENV || '{}') }} |
146 | 177 | run: ${{ inputs.build-command }} |
147 | 178 |
|
148 | 179 | - name: Upload build artifacts (monorepo) |
|
0 commit comments