Upload assets to the CDN ΒΆ
This how-to guide shows you how to upload assets to the CDN.
Prerequisites ΒΆ
- A Nais team.
- A GitHub repository that the team has access to.
- The repository needs to have a GitHub workflow that builds the assets you want to upload.
Authorize repository for upload ΒΆ
- Open Nais console in your browser and select your team.
- Select the
Repositoriestab - Input your repository (
organization/repository) and pressAdd.
Upload assets with the CDN action ΒΆ
In your Github Workflow, add the following step to upload your assets to the CDN.
yaml
name: Push to CDN
on:
push:
branches:
- 'main'
jobs:
upload:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: 'actions/checkout@v4'
- name: Upload static files to CDN
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: <team slug> # Required, e.g. "team-name"
source: <The path to your build folder or assets>
destination: <A destination you pick, like /my-app/dist>
- run: echo uploaded file ${{ steps.upload.outputs.uploaded }}For more information on the inputs and outputs of the action, see the CDN Upload action reference.
Use the uploaded assets ΒΆ
The assets from the CDN will be available at:
Plaintext
https://cdn.nav.no/<team>/<destination>and
Plaintext
https://cdn.nav.cloud.nais.io/<team>/<destination>CORS is automatically configured to accept GET from any origin (*).
Related pages ΒΆ
π― Learn how to manage CDN assets