Skip to main content

Introduction (Optional)

This token serves as an optional component of your deployment process. It's required only if your project integrates with its own design system hosted on GitLab. In such cases, you'll need to generate this token specifically for accessing the resources of your design system.

Generating the token

  1. Navigate to the Acro's GitLab and choose your design system project.
  2. Click on the Settings tab on the sidebar.
  3. Click on the Access Token tab on the sidebar.
  4. Click on the Add new token button.
  5. Fill in the details as follows, replacing <PROJECT_NAME> with the name of your project.
Token Configuration
  • Token name: <PROJECT_NAME>__DS_TOKEN.
  • Role: Reporter.
  • Scopes: read_registry & read_api.
  1. Make sure you keep a copy of the token in a safe place, as we'll need to incorporate it into the project's CI/CD configuration or Lagoon's environment variables.

Deploying on GitLab CI?

Including a token in the CI/CD process is crucial for the project's CI/CD operations during tasks like npm install, which involve linting, testing, and project deployment. In frontend projects, the .gitlab-ci.yml file dynamically generates an .npmrc file, which relies on the provided token.

Adding the token in the project's CI/CD settings

  1. Navigate to the Acro's GitLab and choose the desired project where you wish to add the variable.
  2. Click on the Settings tab on the sidebar.
  3. Click on the CI/CD tab on the sidebar.
  4. Under the Variables section, click on the Expand button.
  5. Click on the Add variable button.
  6. Fill in the details as follows:
Variable Configuration
  • Type: Variable (default)
  • Environments: All (default)
  • Flags: Expand variable reference and Mask variable
  • Key: <PROJECT_NAME>__DS_TOKEN
  • Value: The token value which you've previously generated.

Referencing the token in the GitLab CI file

Once the token is added as a secret variable, it can be referenced in the .gitlab-ci.yml file as shown below:

Frontend project example:

before_script:
- touch .npmrc
- echo "@<PACKAGE_NAMESPACE>:registry=https://git.acromedia.com/api/v4/packages/npm/" >> .npmrc
- echo "//git.acromedia.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=${<PROJECT_NAME>__DS_TOKEN}" >> .npmrc
Note
  • Replace <PACKAGE_NAMESPACE> with the namespace of your project found in your composer.json file.
  • Replace <PROJECT_ID>with the ID of your project. For more details how to find this ID, refer to the Finding your Project's Group ID section.
  • Replace <PROJECT_NAME>__DS_TOKEN with the name of the token you've previously assigned.

Deploying on Lagoon?

Add the token as an environment variable through the Lagoon dashboard by following the steps below:

Adding the token as a project variable

  1. Navigate to the Lagoon dashboard and choose the desired project where you wish to add the variable.
  2. Click on the Variables tab on the sidebar.
  3. Click on the Add button.
  4. Fill in the details as follows, replacing <PROJECT_NAME> with the name of your project.
Variable Configuration
  • Scope: Build
  • Name: <PROJECT_NAME>__DS_TOKEN
  • Value: The token value which you've previously generated.
  1. Click on the Add project variable button to add the variable.
  2. Trigger a redeployment of your project environments to apply the changes and ensure the variable becomes available.

Referencing the token in the docker file

Once the token is added as a project variable, it can be referenced in your docker file (eg. ./lagoon/cli.dockerfile) as shown below:

ARG <PROJECT_NAME>__DS_TOKEN
RUN echo "@<PACKAGE_NAMESPACE>:registry=https://git.acromedia.com/api/v4/packages/npm/" >> .npmrc
RUN echo "//git.acromedia.com/api/v4/projects/<PROJECT_ID>/packages/npm/:_authToken=${<PROJECT_NAME>__DS_TOKEN}" >> .npmrc
Note
  • Replace <PACKAGE_NAMESPACE> with the namespace of your project found in your composer.json file.
  • Replace <PROJECT_ID>with the ID of your project. For more details how to find this ID, refer to the Finding your Project's Group ID section.
  • Replace <PROJECT_NAME>__DS_TOKEN with the name of the token you've previously assigned.