|
| 1 | +// This script retrieves the pathPrefix from the gatsby-config.js file. |
| 2 | +// It serves as an example for how to set up external javascript functions |
| 3 | +// outside workflow .yml files when they get too big or complex to keep them inline. |
| 4 | + |
| 5 | +// Documentation for the actions/github-script: |
| 6 | +// https://github.com/actions/github-script#run-a-separate-file |
| 7 | + |
| 8 | +module.exports = async ({ core }) => { |
| 9 | + const { pathPrefix } = await require('../../gatsby-config.js'); |
| 10 | + |
| 11 | + if (!pathPrefix) { |
| 12 | + core.setFailed( |
| 13 | + `The pathPrefix in the site's gatsby-config.js file is missing. |
| 14 | +
|
| 15 | + To fix this, open your gatsby-config.js file, and add it to the config object: |
| 16 | +
|
| 17 | + module.exports = { |
| 18 | + pathPrefix: "/commerce/frontend-core/", |
| 19 | + ... |
| 20 | + }` |
| 21 | + ); |
| 22 | + } else if (pathPrefix === '/') { |
| 23 | + core.setFailed( |
| 24 | + `The pathPrefix in the site's gatsby-config.js file is set to "/". This is not allowed. |
| 25 | +
|
| 26 | + To fix this, change the pathPrefix to include a name that starts and ends with "/": |
| 27 | +
|
| 28 | + pathPrefix: "/commerce/frontend - core/" |
| 29 | +
|
| 30 | + This name identifies the site within the developer.adobe.com domain: |
| 31 | + https://developer.adobe.com/document-services/<PATH_TO_FILES>. |
| 32 | + ` |
| 33 | + ); |
| 34 | + } else { |
| 35 | + if (!pathPrefix.startsWith('/') || !pathPrefix.endsWith('/')) { |
| 36 | + core.setFailed( |
| 37 | + `The pathPrefix in the site's gatsby-config.js file does not start or end with "/". |
| 38 | +
|
| 39 | + To fix this, change the pathPrefix to include a name that starts and ends with "/". |
| 40 | + For example: "/document-services/" or "/commerce/cloud-tools/". |
| 41 | +
|
| 42 | + This is required by convention because of the way we construct site URLs. |
| 43 | + For example: https://developer.adobe.com + /document-services/ + path/to/files/. |
| 44 | + ` |
| 45 | + ); |
| 46 | + } |
| 47 | + } |
| 48 | + core.setOutput('path_prefix', pathPrefix); |
| 49 | +}; |
0 commit comments