Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,34 @@ jobs:
dir: build
functions: "./functions/config.json"

# CLI 7: a manifest entry without a uuid is refused before anything is uploaded.
test-functions-require-uuid:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0

- name: Prepare a manifest without a uuid
run: |
mkdir -p quant/edge-functions
echo 'return new Response("x");' > quant/edge-functions/api.js
echo '[{"type":"function","path":"quant/edge-functions/api.js","description":"No uuid"}]' > quant/edge-functions.json

- name: Deploy must fail before upload
id: deploy
continue-on-error: true
uses: ./
with:
customer: quant
project: github-actions
token: ${{ secrets.QUANT_TOKEN }}
functions: quant/edge-functions.json

- name: The deploy step failed
if: steps.deploy.outcome != 'failure'
run: |
echo "::error::a manifest entry without a uuid was accepted"
exit 1

test-rules-guard:
runs-on: ubuntu-latest
steps:
Expand Down
64 changes: 43 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Deploy to QuantCDN Action

This GitHub Action deploys your static site and/or functions to QuantCDN using the Quant CLI v6.
This GitHub Action deploys your static site and/or functions to QuantCDN using the Quant CLI v7.

## Usage

### Deploy Assets
```yaml
- uses: quantcdn/action-deploy@v6
- uses: quantcdn/deploy-action@v7
with:
customer: your-customer-id
project: your-project-name
Expand All @@ -16,12 +16,12 @@ This GitHub Action deploys your static site and/or functions to QuantCDN using t

### Deploy Functions
```yaml
- uses: quantcdn/action-deploy@v6
- uses: quantcdn/deploy-action@v7
with:
customer: your-customer-id
project: your-project-name
token: ${{ secrets.QUANT_TOKEN }}
functions: './functions.json'
functions: quant/edge-functions.json
```

## Inputs
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
npm run build

- name: Deploy to QuantCDN
uses: quantcdn/action-deploy@v6
uses: quantcdn/deploy-action@v7
with:
customer: your-customer-id
project: your-project-name
Expand All @@ -78,30 +78,37 @@ jobs:

### Functions Deployment

Create a functions configuration file (e.g., `functions.json`):
Declare your functions in `quant/edge-functions.json`. Every entry needs a
`uuid`: it is the function's identity, so keep it in the repository and never
change it. Create entries with `quant functions-add`, which writes a new UUID:

```sh
npx @quantcdn/quant-cli@7 functions-add quant/edge-functions.json quant/edge-functions/api.js --description "API" --id my-api
```

```json
[
{
"type": "auth",
"path": "./functions/auth.js",
"path": "quant/edge-functions/auth.js",
"description": "Authentication function",
"id": "gate",
"uuid": "11111111-1111-4111-a111-111111111111"
},
{
"type": "filter",
"path": "./functions/filter.js",
"description": "Filter function",
"uuid": "22222222-2222-4222-a222-222222222222"
},
{
"type": "function",
"path": "./functions/function.js",
"path": "quant/edge-functions/api.js",
"description": "Edge function",
"id": "my-api",
"uuid": "33333333-3333-4333-a333-333333333333"
}
]
```

`type` is `function`, `edge`, `auth` or `filter`; `id` is optional (a lowercase
slug that rules use as `function_ref`). The whole manifest is checked before the
first upload, and a manifest entry without a `uuid` fails the step.

Then deploy using:
```yaml
name: Deploy Functions to QuantCDN
Expand All @@ -116,12 +123,12 @@ jobs:
- uses: actions/checkout@v6

- name: Deploy Functions
uses: quantcdn/action-deploy@v6
uses: quantcdn/deploy-action@v7
with:
customer: your-customer-id
project: your-project-name
token: ${{ secrets.QUANT_TOKEN }}
functions: './functions.json'
functions: quant/edge-functions.json
```

### Combined Deployment
Expand All @@ -144,28 +151,28 @@ jobs:
npm run build

- name: Deploy to QuantCDN
uses: quantcdn/action-deploy@v6
uses: quantcdn/deploy-action@v7
with:
customer: your-customer-id
project: your-project-name
token: ${{ secrets.QUANT_TOKEN }}
dir: build
functions: './functions.json'
functions: quant/edge-functions.json
```

## Notes

- This action uses Quant CLI v6
- This action uses Quant CLI v7 (`quantcdn/cli:7.0.0@sha256:e9562fac…`, pinned by digest)
- For search functionality, please use the dedicated search action
- Make sure your `QUANT_TOKEN` is stored securely in your repository secrets

## Edge rules

Provide `rules: edge-rules.json`, `functions: edge-functions.json`,
Provide `rules: quant/edge-rules.json`, `functions: quant/edge-functions.json`,
`api-token: ${{ secrets.QUANT_API_TOKEN }}` and
`api-base-url: ${{ vars.QUANT_BASE_URL }}` alongside the normal deployment inputs.
The Quant portal injects the project-scoped API secret and the environment-specific
portal `/api/v2` URL when a static or Studio template includes `edge-rules.json`.
portal `/api/v2` URL when a static or Studio template includes `quant/edge-rules.json`.
Uploads continue to use the separate `token` input. Never substitute the content
write token for `api-token`.

Expand All @@ -192,3 +199,18 @@ idempotent, so the rules step converges and unchanged assets are skipped.
## License

MIT License

## Upgrading from v6 to v7

v7 runs Quant CLI 7.0.0. The only breaking change is for edge functions:

- Every entry in the `functions` manifest needs an explicit `uuid`. v6 derived
one from `id` when it was missing. v7 fails the "Deploy Functions" step (or the
rules dry run, when `rules` is set) before anything is uploaded, and names each
entry. To keep a function v6 deployed by `id`, copy its UUID from the dashboard
(Compute > Edge Functions) into the entry, or see the Quant CLI README for a
command that prints the UUID v6 derived.
- The manifest is checked against the full schema (lowercase `type`, non-blank
`description`, unique `uuid` and `id`).

`@v6` is not changed and keeps CLI 6.3.0.
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ runs:

- name: Validate Rules Access
if: inputs.rules != ''
uses: "docker://quantcdn/cli:6.3.0@sha256:cc5025e8749068b3a445331430d461be9467ce0f811838fdba9710dd388d4054"
uses: "docker://quantcdn/cli:7.0.0@sha256:e9562fac5914c7a8cef3fc4f3ad88004fd125500d8643577dd81cd20e7ee2e33"
env:
QUANT_API_TOKEN: ${{ inputs.api-token }}
QUANT_BASE_URL: ${{ inputs.api-base-url }}
Expand All @@ -96,7 +96,7 @@ runs:

- name: Deploy Functions
if: inputs.functions != ''
uses: "docker://quantcdn/cli:6.3.0@sha256:cc5025e8749068b3a445331430d461be9467ce0f811838fdba9710dd388d4054"
uses: "docker://quantcdn/cli:7.0.0@sha256:e9562fac5914c7a8cef3fc4f3ad88004fd125500d8643577dd81cd20e7ee2e33"
env:
CUSTOMER: ${{ inputs.customer }}
TOKEN: ${{ inputs.token }}
Expand All @@ -113,7 +113,7 @@ runs:

- name: Deploy Assets
if: inputs.dir != ''
uses: "docker://quantcdn/cli:6.3.0@sha256:cc5025e8749068b3a445331430d461be9467ce0f811838fdba9710dd388d4054"
uses: "docker://quantcdn/cli:7.0.0@sha256:e9562fac5914c7a8cef3fc4f3ad88004fd125500d8643577dd81cd20e7ee2e33"
with:
args: >
deploy
Expand All @@ -132,7 +132,7 @@ runs:

- name: Deploy Rules
if: inputs.rules != ''
uses: "docker://quantcdn/cli:6.3.0@sha256:cc5025e8749068b3a445331430d461be9467ce0f811838fdba9710dd388d4054"
uses: "docker://quantcdn/cli:7.0.0@sha256:e9562fac5914c7a8cef3fc4f3ad88004fd125500d8643577dd81cd20e7ee2e33"
env:
QUANT_API_TOKEN: ${{ inputs.api-token }}
QUANT_BASE_URL: ${{ inputs.api-base-url }}
Expand Down
Loading