Authenticating Laravel Nova in a CI/CD pipeline

Published on

To install Laravel Nova in a CI/CD pipeline you'll have to authorize the CI/CD runner to download Nova.

When installing Laravel Nova locally you can just type in your credentials by hand. You can't type by hand in an automated CI/CD pipeline, so you have to use an auth.json file instead. The auth.json file is created by running the composer config command listed lower down in this post.

The auth.json file contains secrets, so you shouldn't commit it to version control. Instead, add the secrets to your CI/CD pipeline.

For GitHub Actions:

Add the following secrets to your GitHub repository:

  • NOVA_USERNAME
  • NOVA_LICENSE_KEY

Then use them in your workflow like this:

- name: Install Composer dependencies
  run: |
    composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}"
    composer install --no-interaction --optimize-autoloader --no-dev

For GitLab CI/CD

In your GitLab repository, go to "repository settings" and then "repository variables" and add the following two values:

  • NOVA_USERNAME
  • NOVA_LICENSE_KEY

Then use them in your pipeline like this:

install_dependencies:
  variables: {
    nova_username: "$NOVA_USERNAME",
    nova_license_key: "$NOVA_LICENSE_KEY",
  }
  script:
    - composer config "http-basic.nova.laravel.com" "$nova_username" "$nova_license_key"
    - composer install --no-interaction --optimize-autoloader --no-dev

For Bitbucket Pipelines

In your Bitbucket repository, go to "repository settings" and then "repository variables" and add the following two values:

  • NOVA_USERNAME
  • NOVA_LICENSE_KEY

Then use them in your pipeline like this:

- step:
      name: Install dependencies
      script:
          - composer config "http-basic.nova.laravel.com" "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
          - composer install --no-interaction --optimize-autoloader --no-dev