Microservice for publishing Project Helix Fastly service configurations
This microservice sets up a Fastly service config so that it can be used for Project Helix-powered websites. This includes:
condition
s specified in helix-config.yaml
params
list from helix-config.yaml
helix-config.yaml
X-Location
headersX-Location
headers and turns them into 301
redirectsThere are a number of important tasks involved in publishing that it does not do:
Send a POST request with following (Content-Type: application/json
-encoded) body parameters to https://adobeioruntime.net/api/v1/web/helix/helix-services/publish@v4
:
configuration
: your helix-config.yaml
, as a JSON documentservice
: the service ID of your Fastly service configtoken
: a Fastly authentication token that has global
permission on the service configversion
: the version number of a checked-out (editable) version of the above service configvcl
: an object containing the name of the vcl file (key) to override and its content. For now, only extensions.vcl
override is supporteddispatchVersion
: the version of the dispatch action to use. Defaults to v3
.You need node>=8.0.0
and npm>=5.4.0
. Follow the typical npm install
, npm test
workflow.
When you run npm test
, some integration tests that require Fastly credentials will be skipped. This means, you won't get full test coverage, which is not an issue, as the credentials will be used in integration tests running on CircleCI.
If you set up a Fastly service configuration and set the HLX_FASTLY_NAMESPACE
, HLX_FASTLY_AUTH
, and VERSION_NUM
environment variables, then re-running npm test
will also include the integration tests and achieve full code coverage. Note that these integration tests override your existing Fastly service configuration and should not be run against a production service config.
If you are having trouble with specific configurations and set-ups, it is possible to intercept the hlx publish
API call with a developer proxy like Charles. To do so, run
NODE_TLS_REJECT_UNAUTHORIZED=0 HTTPS_PROXY=http://localhost:4321 hlx publish
and save the JSON body of the first POST
request made to publish https://adobeioruntime.net/api/v1/web/helix/default/publish
in the test/troubleshoot
directory. Re-running npm test
will now pick up your JSON and use it for an integration test, giving you the ability to debug and step through the execution.
CircleCI will deploy successful builds (passing all tests) to publish https://adobeioruntime.net/api/v1/web/helix/default/publish-test. You can run hlx publish --api-publish publish https://adobeioruntime.net/api/v1/web/helix/default/publish-test
to force Helix to use this alternate deployment during the publish process (you can also deploy helix-publish
to your own namespace and test it there).
Contributions are highly welcome.
Deploying Helix Publish requires the wsk
command line client, authenticated to a namespace of your choice. For Project Helix, we use the helix
namespace.
Run npm run deploy
to do a one-shot deploment of Helix Publish. All commits to main that pass the testing will be deployed automatically.