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.
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:
and
CORS is automatically configured to accept GET from any origin (*).
Related pages¶
 Learn how to manage CDN assets